Jaff
Jaff

Reputation: 185

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.

Upvotes: 3

Views: 889

Answers (2)

Dmitri T
Dmitri T

Reputation: 167992

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.

Upvotes: 1

ararar
ararar

Reputation: 983

You can rearrange your structure so that the response assertion isn't in the same level for the HTTP sampler that you don't want to have assertion on it, like below.

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

Upvotes: 1

Related Questions