how to enable or disable a particular sampler or listener with command line options in jmeter

69 Views Asked by At

I am running Jmeter from jenkins pipeline . My Jmx file has 'Simple data Writer' as listener which I want to enable or disable based on the parameters from jenkins . It is possible to enable / disable the listener with right click but i could not find any means to do the same thing programmatically

enter image description here

2

There are 2 best solutions below

1
Yousha Aleayoub On

If I understand your question correctly, you should use this command:

jmeter -Jsampler.YOURSAMPLER.enabled=true -Jlistener.YOURLISTENER.enabled=false -n -t YOURFILENAME.jmx -l YOURRESULTFILE.jtl 

By using this command, you can enable or disable specific sampler or listener in JMeter.

0
Dmitri T On

JMeter .jmx test scripts are basically XML files so you can change the parameter using sed editor before running the test:

sed -i '/<ResultCollector guiclass="SimpleDataWriter" testclass="ResultCollector" testname="Simple Data Writer" enabled="true">/ s/enabled="true"/enabled="false"/' /path/to/your/test.jmx 

Alternatively you can consider using Taurus tool, it has ability to run existing JMeter tests and change any parameter you can think of on the fly. Check out The Complete Taurus Course if you're interested in Taurus framework