I am quite new to Jmeter and trying to code and run jmeter using JAVA by following:
https://www.blazemeter.com/blog/5-ways-launch-jmeter-test-without-using-jmeter-gui/ https://bitbucket.org/blazemeter/jmeter-from-code/src/master/src/main/java/com/blazemeter/demo/JMeterFromScratch.java
if (jmeterHome.exists()) {
File jmeterProperties = new File(jmeterHome.getPath() + slash + "bin" + slash + "jmeter.properties");
if (jmeterProperties.exists()) {
//JMeter Engine
StandardJMeterEngine jmeter = new StandardJMeterEngine();
//JMeter initialization (properties, log levels, locale, etc)
JMeterUtils.setJMeterHome(jmeterHome.getPath());
JMeterUtils.loadJMeterProperties(jmeterProperties.getPath());
Cannot I use like this
StandardJMeterEngine jmeter = new StandardJMeterEngine();
JMeterUtils.getJMeterHome();
JMeterUtils.getJMeterProperties();
I am getting an error when I use the above code
ERROR org.apache.jmeter.save.SaveService - Can't compute checksum for saveservice properties file Exception in thread "main" org.apache.jorphan.util.JMeterError: JMeter requires the checksum of saveservice properties file to continue
Cannot we point to the jmeter jar downloaded through Maven instead of pointing to jmeter property path ? Can anyone help me out ?
The error you're getting indicates that JMeter fails to read saveservice.properties file.
The file is not a part of any JMeter .jar libraries, you will need to have it in the "bin" subfolder of the folder you specify via JMeterUtils.setJMeterHome() function.
If you invoke JMeterUtils.getJMeterHome() function prior to setting it - you will get null
and if you refer the value somewhere else - you will get a NPE
Assuming all above:
saveservice.properties
in that folderIt might be easier to use Taurus tool for unattended programmatic JMeter tests execution, Taurus provides possibility to execute existing JMeter tests and create new ones using simple YAML syntax. See Navigating your First Steps Using Taurus article for more information on the concept
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.