如何在JMeter的While控制器中过滤掉最后一个采样器?

时间:2020-04-13 12:58:24

标签: websocket while-loop jmeter

我的测试计划如下:

Thread group
    \_..other items
    \_While controller (with blank condition)
        \_Web socket single read sampler
    \_..other items

我的问题是,由于我使用空白条件,因此While控制器将执行直到采样器错误为止。所以我的问题是,有没有办法过滤掉最后一个采样器?由于必须执行子采样器的次数不是恒定的,因此在While控制器中没有其他条件可以使用。

谢谢!

1 个答案:

答案 0 :(得分:0)

  1. JSR223 PostProcessor添加为WebSocket单次读取采样器的子项
  2. 将以下代码放入“脚本”区域:

    if (!prev.isSuccessful()) {
        prev.setIgnore()
    }
    

    enter image description here

在上面的代码中,prev代表父SampleResult,而setIgnore()函数告诉JMeter不要为给定的Sampler收集结果。

有关此快捷方式和其他JMeter API快捷方式的更多信息:Top 8 JMeter Java Classes You Should Be Using with Groovy

相关问题