I have few variable in my jmeter script such as $Z{name}, ${DOBZ}, ${SSN} and so on and during the test run I like to save these passed values into a file either txt or csv. Any ideas how to do it or is there are any beanshell code available which I can use to save parameter or any dynamic regular exp values from my script.
2 Answers
You can configure JMeter so it will automatically save variables into .jtl file using sample_variables property.
From the documentation:
Optional list of JMeter variable names whose values are to be saved in the result data files. Use commas to separate the names. For example:
sample_variables=SESSION_ID,REFERENCE
N.B. The current implementation saves the values in XML as attributes, so the names must be valid XML names. Versions of JMeter after 2.3.2 send the variable to all servers to ensure that the correct data is available at the client.
If you run JMeter in command-line non-GUI mode as follows:
jmeter -Jsample_variables=name,DOBZ,SSN -n -t /path/to/your/testplan.jmx -l /path/to/testresults.jtl
You'll see output like:
1419084819822,465,HTTP Request,200,OK,Thread Group 1-1,text,true,1591,1,1,465,${name} variable value,${DOBZ} variable value, ${SSN} variable value
Alternatively you can:
- set
sample_variablesproperty in user.properties file - uncomment
sample_variablesproperty in jmeter.properties file and set it to desired value
For more information on different JMeter properties and ways of setting and overriding them see Apache JMeter Properties Customization Guide