'Can I Set The Number Of Threads From An External FIle in Apache Jmeter?

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?



Solution 1:[1]

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. 

enter image description here

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

Solution 2:[2]

For me that solution it returns error when using the properties file, using the args in command line it is ok. How does jmeter knows that the values come from that properties file?

I am working on a mac. enter image description here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Dmitri T
Solution 2 Janie