Wednesday, November 11, 2009

Dependent tests in JMeter (kind of)

A common use case in testing is the concept of dependent tests(except for the unit test fanatics who love JUnit and didn't realise they needed this functionality till TestNG came along). One of the requirements then becomes that these dependent test should not execute if the test that it depends on fails. To implement this in JMeter we need to use the following two pieces of information
The variable JMeterThread.last_sample_ok is set to "true" or "false" after all assertions for a sampler have been run. [1]
If Controller -Evaluate for all children - Should condition be evaluated for all children? If not checked, then the condition is only evaluated on entry.[2]

Combining the two bits of information we have
Thread Group
If Controller((${JMeterThread.last_sample_
ok}) with Evaluate for all children = checked
Req 1 --> if this errors req 1 and req 2 wont be executed
Req 2 --> if this errors , req 3 wont be executed
Req 3
Note that any assertion failing would also mark the request as failed.
Note also that you cannot have nested dependent sets but you could flatten them out as separate IF controllers.



Anonymous said...

Thank you for this information. I was just looking for something like this for my project!

Franco said...


regarding this functionality I recently made some changes to JMeter's thread group to add it.

The code can be found at the following link: in case anyone is interested and wants to try it, improve it or propose changes.

Thanks for all the work here, it's been really useful.

Deepak Shetty said...

great , Ill take a look at it sometime