I'm trying to execute the JMeter test case using the following command. Do I have another way of executing the test cases without having JMeter installed locally? Here I have to provide JMeter HOME path to JMeterUtils.
// JMeter Engine
StandardJMeterEngine jmeter = new StandardJMeterEngine();
// Initialize Properties, logging, locale, etc.
JMeterUtils.loadJMeterProperties("/path/to/your/jmeter/bin/jmeter.properties");
JMeterUtils.setJMeterHome("/path/to/your/jmeter");
JMeterUtils.initLogging();// you can comment this line out to see extra log messages of i.e. DEBUG level
JMeterUtils.initLocale();
// Initialize JMeter SaveService
SaveService.loadProperties();
// Load existing .jmx Test Plan
FileInputStream in = new FileInputStream("/path/to/your/jmeter/extras/Test.jmx");
HashTree testPlanTree = SaveService.loadTree(in);
in.close();
// Run JMeter Test
jmeter.configure(testPlanTree);
jmeter.run();
}
resorce https://www.blazemeter.com/blog/5-ways-launch-jmeter-test-without-using-jmeter-gui
You don't actually need to have a complete JMeter installation in this home directory you set. Just the property files are enough. In your JMeter home directory (or sub directories) you can put any additional property file like saveservice.properties, user.properties and so on. These are normally reference by relative paths inside the jmeter.property file. That is why you need a home directory...
So no local installation is needed for running a test plan from java. You just need the property files to be present. By setting JMeterHome you just tell JMeter where to look for additional property files specified in the jmeter.properties file.
For a working project i would suggest looking into this:
https://bitbucket.org/blazemeter/jmeter-from-code/
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With