【问题标题】:Ignore a global response assertion in Jmeter忽略 Jmeter 中的全局响应断言
【发布时间】:2017-12-15 14:28:36
【问题描述】:

假设结构如下:

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

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

谢谢大家。

【问题讨论】:

  • sampler4能一直成功吗?
  • 不,我希望它忽略全局断言并给它自己的断言。

标签: jmeter beanshell assertion


【解决方案1】:

鉴于标签中有beanshell,我的期望是您的Global Response AssertionBeanshell Assertion。如果是这样 - 您可以“忽略”Http Sampler4,如下所示:

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

还要注意 JMeter 中的 starting from JMeter version 3.1 it is recommended to use Groovy for any form of scripting,因此请考虑在下次有机会时迁移到 JSR223 Assertion

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

【讨论】:

    【解决方案2】:

    您可以重新排列您的结构,以便响应断言与您不希望对其进行断言的 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 脚本或其他东西来做?
    • 也许你可以用 beanshell 断言替换你的响应断言,那么也许可以,否则我认为不可能。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多