Jmeter assertion priority

506 views Asked by At

Are the assertions in JMeter, executed/checked on the basis of the order of occurrence or randomly ?

I am having two (or more) assertions to all of my HTTP requests, one of them is always a response assertion checking the response code. Other one being more detailed BSF Assertion. If my response code assertion fails I don't care if the other assertion passes or fails, so I don't want it to be executed/checked.

Any suggestions for the same ?

2

There are 2 answers

1
Dmitri T On BEST ANSWER

Assertions are executed upside down. So if you put BSF Assertion under Response Assertion and populate it as follows:

if (SampleResult.isSuccessful()){
    //your extended assertion logic here
}

extended BSF Assertion will be fired only if the following conditions are met:

  • Parent sample success
  • Response assertion success

If the any of condition fails only first line of the extended BSF Assertion will be executed.

For more information on using JMeter Assertions see How to Use JMeter Assertions in 3 Easy Steps guide.

1
Zubair M Hamdani On

Assertions are executed on basis of the order of occurrence, and currently in Jmeter there is no mechanism to skip/ignore any one assertion based on the result from previous assertion.

Probably you can combine both assertions in to BSF Assertion
where you first do a check on response code and if response code is correct/expected then do the detailed assertion.

hope this will help.