1
votes

I am currently using JMeter 5.1.1 on a Mac and have developed a very simple JMeter project to test out property value substitutions via Command Line. My JMeter project is pretty simple with a Dummy Sampler trying to print out the following

${__P(resources.folder)}, ${__P(propertiesfile)} and ${__property(propertiesfile)}

Link to JMeter project image

I am trying to run this project via CLI using the command

jmeter -n -t TestProj.jmx -l jmeter/TestProjResults.jtl -j jmeter/TestProj.log -Dresources.folder=/Users/h244955/Coding/bga/spogdashboard/tests/perf -Dpropertiesfile=baforgeperfproperties

The values are not getting substituted and I am seeing the following in the log:

2019-10-22 20:48:09,531 DEBUG o.a.j.e.u.ValueReplacer: About to replace in property of type: class org.apache.jmeter.testelement.property.StringProperty: ${__P(resources.folder)} ${__P(propertiesfile)} ${__property(propertiesfile)} 2019-10-22 20:48:09,533 DEBUG o.a.j.t.p.AbstractProperty: Not running version, return raw function string 2019-10-22 20:48:09,533 DEBUG o.a.j.e.u.ValueReplacer: Replacement result: ${__P(resources.folder)} ${__P(propertiesfile)} ${__property(propertiesfile)} 2019-10-22 20:48:09,534 DEBUG o.a.j.e.u.ValueReplacer: About to replace in property of type: class org.apache.jmeter.testelement.property.StringProperty: Dummy Sampler used to simulate requests and responses without actual network activity. This helps debugging tests. 2019-10-22 20:48:09,534 DEBUG o.a.j.e.u.ValueReplacer: Replacement result: Dummy Sampler used to simulate requests and responses without actual network activity. This helps debugging tests. 2019-10-22 20:48:09,534 DEBUG o.a.j.e.u.ValueReplacer: About to replace in property of type: class org.apache.jmeter.testelement.property.StringProperty: ${__Random(50,500)} 2019-10-22 20:48:09,534 DEBUG o.a.j.t.p.AbstractProperty: Not running version, return raw function string 2019-10-22 20:48:09,534 DEBUG o.a.j.e.u.ValueReplacer: Replacement result: ${__Random(50,500)}

However, when I run this project from GUI with the help of declaring the same properties using a JSR223 Sampler, the values are getting substituted in the Dummy Sampler as expected. I tried looking around for answers for the highlighted log above, but in vain.

2

2 Answers

0
votes

You need to override JMeter property using -J:

 jmeter -n -t TestProj.jmx -Jresources.folder=/Users/h244955/Coding/bga/spogdashboard/tests/perf -Jpropertiesfile=baforgeperfproperties -l jmeter/TestProjResults.jtl -j jmeter/TestProj.log 

-D[prop_name]=[value] defines a java system property value. -J[prop_name]=[value] defines a local JMeter property.

To add additional JMeter property file use -q

-q, --addprop <argument>
    additional JMeter property file(s)
0
votes

I cannot reproduce the issue:

enter image description here

so my expectation is that your JMeter installation is broken somehow, i.e. make sure that ApacheJMeter_functions.jar file is present in "lib/ext" folder of your JMeter installation

  1. Make sure to get JMeter from the official downloads page and check the downloaded archive integrity, check How to Get Started With JMeter: Part 1 - Installation & Test Plans article for details.
  2. Make sure to launch JMeter from its "bin" folder, to wit

    cd /path/where/jmeter/lives/bin 
    ./jmeter -Dpropertiesfile=baforgeperfproperties -n -t test.jmx ....
    

    this ./jmeter bit is important to ensure that you launch JMeter from the current folder, not from another folder in your MacOS PATH