Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: [Original edit by JMeterAdmin] Clarify SFF example

...

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.

...

  1. Start JMeter
  2. Add a Thread Group to the Test Plan
    1. set the appropriate number of threads and iterations
  3. Add Pre Processors > User Parameters to Thread Group
  4. Click Add Variable
    1. Set Update once per iteration
    2. Set the Name to the name of the variable (e.g. ACCOUNTID)
      1. Set the value (under User_1) to ${_StringFromFile(accounts.dat)}
  5. Add Sampler > HTTP Request to Thread Group:
  6. Click the Add button to add a parameter to the request:
    1. Name: account_id
    2. Value: ${ACCOUNTID}
  7. Add Listener > View Results Tree to Thread Group
  8. Save
    Wiki Markupcreate 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. {${_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.

...