0

I have followed the example given in How to create and run Apache JMeter Test Scripts from a Java program? . The sample program runs the tree configured to the JMeter engine, I want to collect back the response, actual request, and assertion data. I have tried in a way below

SampleResult sampleResult = httpSamplerProxy.sample();

but this re-submits my request to API. Is there any way that I can get the results back without resubmission?

Balu
  • 141
  • 3
  • 17

1 Answers1

0

If you want to "collect" this data amend your test configuration to store execution results into a .jtl results file like:

Summariser summer = null;
String summariserName = JMeterUtils.getPropDefault("summariser.name", "summary");
if (summariserName.length() > 0) {
    summer = new Summariser(summariserName);
}


// Store execution results into a .jtl file
String logFile = "/path/to/results.jtl"
ResultCollector logger = new ResultCollector(summer);
logger.setFilename(logFile);
hashTree.add(hashTree.getArray()[0], logger);

And then configure what you would like to store in its file using "normal" JMeter Properties, i.e. by adding the next lines to user.properties (located in "bin" folder of your JMeter installation:

jmeter.save.saveservice.output_format=xml
jmeter.save.saveservice.response_data=true
jmeter.save.saveservice.samplerData=true
jmeter.save.saveservice.requestHeaders=true
jmeter.save.saveservice.url=true
jmeter.save.saveservice.responseHeaders=true

References:

Dmitri T
  • 159,985
  • 5
  • 83
  • 133