...
if you omit the value, it defaults to 1
How do I use external data files to define variables in my Test scripts?
Wiki Markup |
---|
*Answer:*The \[http://jakarta.apache.org/jmeter/usermanual/component_reference.html#CSV_Data_Set_Config CSV Data Set Config\] element is the best way to do this, as it can create multiple variables from a single data file. |
*Answer:*Another way to do this is to create a One way to do this is to create a User Parameters Pre-Processor in which you list all the values that you want to read from files. You can then use the variable names later in the script.
...
- Start JMeter
- Add a Thread Group to the Test Plan
- set the appropriate number of threads and iterations
- Add Pre Processors > User Parameters to Thread Group
- Click Add Variable
- Set Update once per iteration
- Set the Name to the name of the variable (e.g. ACCOUNTID)
1. Set the value (under User_1) to${_StringFromFile(accounts.dat)
}
- Add Sampler > HTTP Request to Thread Group:
- Click the Add button to add a parameter to the request:
- Name: account_id
- Value: ${ACCOUNTID}
- Add Listener > View Results Tree to Thread Group
- Save
create the file 1. create the file accounts.dat containing one line per account id. \[In the bin directory, unless you add a path to the parameter to _StringFromFile\]If it is not in the bin directory, then modify the String{{`From}}`File parameter accordingly, e.g. {Wiki Markup ${_StringFromFile(../testdata/accounts.dat)} or ${_StringFromFile(/home/user/testdata/accounts.dat)} or ${_StringFromFile(C:/work/data/accounts.dat)
}}
1. Run > Start
Each iteration, the ACCOUNTID variable will be set to the next line in the file, and the HTTP Request will use its value to set the account_id parameter.
...
Wiki Markup lib/ext, where the \["ApacheJMeter"\]_\*.jar files live
- lib, where the 3rd party jar files live
Additional jars should normally be placed in the lib directory; however, if you have written an add-on for JMeter itself, that should be put in the lib/ext directory.
...