-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

JMeter Cookbook
By :

More often than not, we will need to provide varying input datasets to our scripts to simulate realistic user interaction with an application. Most applications, for instance, need to be authenticated against to view certain restrictive areas of the application. The way to accomplish this is by supplying an input datafile to the test script. The file is normally in the form of comma-separated values (CSV).
This recipe shows you how to feed data into your script to handle such scenarios. Perform the following steps:
Alternatively, you can clone the sample from the GitHub repository at http://github.com/jmeter-cookbook/bundled-code.
ch1_feed_me_data.jmx
script from the scripts/ch1
directory.input.txt
.Assuming you haven't changed the default sharing mode of the added CSV dataset configuration, with each iteration run of our test plan, a line of the input.txt
file is consumed. The consumed values are then turned into JMeter variables named after the first line of our input datafile, which are user
and pass
in our case. The values are then used further down the execution chain to fill in the username and password to access our application. In this particular test plan, as we have more threads than the amount of input data, the input data is recycled once the end of the file is reached.
In our example, we have just provided the name of the file to read the input feed from. If you examine the CSV dataset configuration element closely, you will notice that it has other properties that can be filled in. These include the following:
\t
) or the colon symbol (:
) instead of commas.'hello'
as opposed to hello
.All meaning all threads
; even those in a different thread group get to share the same data. The other options are Current thread group and Current thread, which specify that only the threads within a particular thread group and only a particular thread can retrieve data from the file, respectively.Change the font size
Change margin width
Change background colour