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.
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.
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.
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.
In CSV Data Set Config instead of hard-coded filename use JMeter property reference via __P() or __property() function like:
${__property(csvfile,,)}
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With