Jmeter Groovy 断言关键字不会导致树视图侦听器中的断言失败

Jmeter Groovy Assert Keyword is not Causing Assertion Failure in Tree View Listener

是否可以在 JSR223 断言中使用这行代码在树视图侦听器中断言失败?

assert 1 == 2

在 JMeter 3.1 版之前,我可以毫无问题地执行此操作,但现在它无法正常工作。我知道我可以使用这些代码行

if(1 != 2) {
AssertionResult.setFailure(true)
AssertionResult.setFailureMessage('They are not equal') }

但如果可能的话,我希望它像以前一样更简单、更短,只需要一行代码

我确认可以在 JMeter 3.3(截至目前的最新版本)中使用上述代码使采样器失败

确保:

  1. 您想要失败的采样器位于 Assertion Scope
  2. 中的某处
  3. 你有groovy-all.jar in JMeter Classpath
  4. jmeter.log 文件
  5. 中没有任何可疑条目

在下一个 4.0 版本中可以使用 assert,如下所示:

你可以试试jmeter nightlty build:

我认为在 3.1 中不可能做到这一点