Search code examples
jmeterbeanshellassertion

Ignore a global response assertion in Jmeter


Assume the structure below:

Thread Group
      -Simple Controller
                   -Global Response Assertion
                   -Http Sampler1
                   -Http Sampler2
                   -Http Sampler3
                   -Http Sampler4
                    etc

So the global response assertion will work on all the samplers below it. However, I need a way for a specific sampler to ignore the global assertion so for example i want HTTP sampler4 not to be asserted by the global assertion and to completely ignore it.

Thanks everyone.


Solution

  • Given you have beanshell in tags my expectation is that your Global Response Assertion is a Beanshell Assertion. If so - you can "ignore" the Http Sampler4 as follows:

    if (SampleResult.getSampleLabel().equals("Http Sampler4")) {
        // do nothing
    }
    else {
        // your "global assertion" logic here 
    }
    

    Also be aware that starting from JMeter version 3.1 it is recommended to use Groovy for any form of scripting in JMeter so consider migrating to JSR223 Assertion on next available opportunity.

    See Apache Groovy - Why and How You Should Use It guide for more details.