I have many JMeter scripts that are testing different scenarios and I want to create a configuration file for some common values across my scripts, so I will not have to edit each one to change let's say the Number of Threads.
I tried the following method but without success: I created a CSV file to contain the number of threads and passed this variable inside the Thread Group.
There is no error, but the script is not starting, always showing: "Starting 0 threads for group Thread Group."
Is there a way to set the Number of Threads from an external file?
It is, you need to create a .properties file like settings.properties
and define the values there for example:
number.of.threads=100
number.of.loops=10
etc.
And refer the properties in the Thread Group via __P() function:
- ${__P(number.of.threads,)}
- ${__P(number.of.loops,)}
- etc.
Once done you can pass the file to JMeter using -q
command line argument:
jmeter -q settings.properties -n -t test.jmx -l result.jtl
You can also override the values from the command-line using -J
command-line argument like:
jmeter -Jnumber.of.threads=10 -n -t test.jmx -l result.jtl
More information: Apache JMeter Properties Customization Guide