Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing csv data set config file as parameter to JMeter

Tags:

jmeter

I would like to be able to pass a CSV file containing parameters for a JMeter test (CSV Data Set Config) to use instead of having the CSV Data Source hard coded as part of the JMeter test. Is this possible? I cannot seem to find this anywhere / in the list of command-line options for JMeter.

Reference for JMeter Data Set Config.

like image 379
betawave92 Avatar asked Jun 28 '16 17:06

betawave92


People also ask

What is CSV data set config in JMeter?

The “CSV Data Set Config” enables using CSV files as an external data source, where you can keep unique user data like names, emails and passwords. With the help of this config element, JMeter is able to read the CSV file line by line, and then use split parameters to allocate different values for different threads.

How do I select different CSV files in JMeter runtime?

Now, the function __CSVRead will take the data from the CSV with the same name of the user we use for the login. This way we can use different CSVs and pick them correctly at runtime. This is the complete flow: In each execution, the "CSV Data Set Config" picks a new user and pass from the users.


1 Answers

It is possible, but don't use JMeter Variables as a part of CSV Filename as they are being initialized after CSV Data Set Config so you'll get "file not found" errors. Go for JMeter Properties instead.

  1. In CSV Data Set Config instead of hard-coded filename use JMeter property reference via __P() or __property() function like:

    • ${__P(csvfile,)}
    • ${__property(csvfile,,)}

      CSV File Property Name

  2. Aforementioned csvfile property which pointing to the CSV file path can be defined in 2 ways:

    • in user.properties file (lives in JMeter's "bin" folder) like:

      csvfile=/path/to/your/file.csv
      
    • via -J command-line argument like

      jmeter -Jcsvfile=/path/to/file.csv -n -t test.jmx -l results.jtl
      

    Property value specified via command-line will override the one which is stored in the file. See Apache JMeter Properties Customization Guide for more information regarding JMeter properties and ways of working with them

like image 52
Dmitri T Avatar answered Sep 25 '22 23:09

Dmitri T