Search code examples
jmeterassertionsbeanshell

Jmeter assertion priority


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 ?


Solution

  • 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.