Auth0 Home Blog Docs

How to get Jmeter test result from JAVA Class by using JMeter API

jmeter
jmeter_online
jmeter_training

#1

I’m new to JMeter. I found the following code to run a JMeter test plan(.jmx) from JAVA project by using JMeter API StandardJMeterEngine.
But how can I get the execution result as return?
I saw many articles about SampleResult. If this is a solution, can you please provide details about how can I integrate my sampleResult into the existing JMeter test plan.
// JMeter Engine
StandardJMeterEngine jmeter = new StandardJMeterEngine();

// Initialize Properties, logging, locale, etc.
JMeterUtils.loadJMeterProperties("../jmeter.properties");
JMeterUtils.setJMeterHome("../apache-jmeter-2.11");
JMeterUtils.initLogging();
JMeterUtils.initLocale();

SaveService.loadProperties();

// Load existing .jmx Test Plan
FileInputStream in = new FileInputStream("../Integ.jmx");
HashTree testPlanTree = SaveService.loadTree(in);
in.close();
// Run JMeter Test
jmeter.configure(testPlanTree);
jmeter.run();
<how to capture result here?????????????????>
jmeter.exit();

#2