JMeter function ${__time()} embedded in HTTP Request body doesn't work when running .jmx through java. It works perfectly fine when running the test in JMeter GUI. Can someone please provide any pointers? I even tried to assign this function to a variable in JMeterGUI and then used that variable in json body but again it works in GUI but not when running .jmx file through Java, My API responds with 400 bad request means incorrect body.
HTTP Request Json Body in Jmeter GUI:
{"UniqID" : ${__time()}}
My Java code:
JMeterUtils.loadJMeterProperties("../bin/jmeter.properties");
JMeterUtils.setJMeterHome("../jMeter");
JMeterUtils.initLocale();
SaveService.loadProperties();
File jmxFile = new File(".../test.jmx");
HashTree testPlanTree = SaveService.loadTree(jmxFile);
StandardJMeterEngine jMeterEngine = new StandardJMeterEngine();
jMeterEngine.configure(testPlanTree);
jMeterEngine.
jMeterEngine.run();
jMeterEngine.exit();
Update:
I copied ApacheJMeter_functions.jar from gradle local folder ..\Users\.gradle\caches\modules-2\files-2.1\org.apache.jmeter\ApacheJMeter_functions\ to ../jMeter/lib/ext which is a sub-directory in jMeter home path set in my code above and it worked.
But now the question is how do I achieve this with just the gradle dependency and not by adding actual jar to jMeter home as I cant upload jar files to git.