忽略 Jmeter 中的全局响应断言

Ignore a global response assertion in Jmeter

假设结构如下:

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

因此全局响应断言将适用于它下面的所有采样器。但是,我需要一种方法让特定采样器忽略全局断言,例如我希望 HTTP 采样器 4 不被全局断言断言并完全忽略它。

谢谢大家

您可以重新安排您的结构,使响应断言与您不想对其进行断言的 HTTP 采样器不在同一级别,如下所示。

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

鉴于您的标签中有 beanshell,我预计您的 Global Response AssertionBeanshell Assertion。如果是这样 - 您可以 "ignore" Http Sampler4 如下:

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

另请注意 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 下次有空的机会。

有关详细信息,请参阅 Apache Groovy - Why and How You Should Use It 指南。