Assert Avg Time and standard deviation using Jmeter java client

189 views Asked by At

I have been using ApacheJMeter_core and ApacheJMeter_http libraries to create and run Jmeter testplan from java Junit file.

My test plan is of below structure

  • POST thread group

    • POST api call for duration 20 secs
  • GET thread group

    • GET api call for duration 20 secs

Summariser is added for each thread group

When i set loopController.setLoops(<some value>); I could see below correct logs in System out

GET_Result = 16 in 00:00:01 = 15.8/s Avg: 61 Min: 4 Max: 287 Err: 0 (0.00%) POST_Result = 4 in 00:00:01 = 3.9/s Avg: 260 Min: 36 Max: 485 Err: 0 (0.00%)

But when I use loopController.setContinueForever(true); and getThreadGroup.setScheduler(true);getThreadGroup.setDuration(20); postThreadGroup.setScheduler(true);postThreadGroup.setDuration(20); I don't see results printing in System logs.

The log is as below

0 in 00:00:00 = ******/s Avg:     0 Min: 9223372036854775807 Max: -9223372036854775808 Err:     0 (0.00%)

Did I miss something? Appreciate any help

I would also like to know how the values can be asserted in the Junit file. Is it possible to get Avg, Standard Deviation of results and assert the values

Thanks

1

There are 1 answers

0
Dmitri T On

Replace your

loopController.setContinueForever(true);

with

loopController.setLoops(-1);

See Five Ways To Launch a JMeter Test without Using the JMeter GUI article for more information on different ways of headless JMeter tests execution including programmatic.


Be aware that the only officially recommended way of creating a JMeter test is via JMeter GUI, other approaches exist but you use them on your own risk. The easiest way of creating a JMeter test programmatically is using Taurus tool.