在JMeter中有条件地停止用户线程

San*_*air 8 jmeter

我有一个为x个用户运行的JMeter脚本.我想有条件地关闭while控制器中的用户线程.例如,如果我的while控制器退出用户线程,我需要停止该线程.可能吗?对不起,如果这是重复或愚蠢的问题.

Dmi*_*i T 12

关于如何有条件地停止测试线程甚至整个测试,至少有两个选项:

  1. Test Action sampler与If Controller结合使用
  2. 使用Beanshell Sampler或PostProcessor并调用SampleResult类的setStopThread方法.有关示例,请参见如何使用BeanShell指南.以供参考:

    if (condition){
        SampleResult.setStopThread(true); // for Beanshell Sampler
        prev.setStopThread(true); // for Beanshell Post Processor
    }
    
    Run Code Online (Sandbox Code Playgroud)