Reputation: 1076
I'm creating a JMeter test for EJB method calls extending AbstractJavaSamplerClient class. I have several method calls which has to be done in order and I want to get response times each of them. Is it somehow possible to get JMeter to report several response times from one test class? I've not found a way to do this.
EDIT1: So I would like to get separate response times from call1 and call2.
public class JavaRequestSamplerDemo extends AbstractJavaSamplerClient {
@Override
public SampleResult runTest(JavaSamplerContext ctx) {
SampleResult sampleResult = new SampleResult();
sampleResult.sampleStart();
class.call1();
class.call2();
sampleResult.sampleEnd();
sampleResult.setSuccessful(true);
sampleResult.setResponseCodeOK();
sampleResult.setResponseMessageOK();
return sampleResult;
}
}
Upvotes: 2
Views: 2641
Reputation: 591
As promised in the comment, try this:
public class JavaRequestSamplerDemo extends AbstractJavaSamplerClient {
@Override
public SampleResult runTest(JavaSamplerContext ctx) {
SampleResult mainResult = new SampleResult();
mainResult.sampleStart();
SampleResult child = new SampleResult();
child.sampleStart();
class.call1();
child.sampleEnd();
// set the other properties of the 'child' SampleResult, such as successful etc here.
mainResult.addSubResult(child);
child = new SampleResult();
child.sampleStart();
class.call2();
child.sampleEnd();
// again, set the properties of this child appropriately (successful etc).
mainResult.addSubResult(child);
mainResult.setSuccessful(true);
mainResult.setResponseCodeOK();
mainResult.setResponseMessageOK();
return mainResult;
}
}
NB, the downside is that none of the native JMeter Listeners support SubResults. I wrote a few and have posted an example in the answers to this question: Jmeter Graph Listener for SampleResult.subResult
Upvotes: 3