Run JMeter test case by a Java Stand-Alone Application, without having JMeter installed locally.

Kasun Weerakoon :

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

Yordan Boev :

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.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=469753&siteId=1