在JMeter中有条件地停止用户线程
问题内容:
我有一个XM用户脚本正在运行。我想有条件地关闭while控制器中的用户线程。例如,如果我的while控制器退出了用户线程,则需要停止线程。可能吗?很抱歉,如果这是重复的或愚蠢的问题。
问题答案:
关于如何有条件地停止测试线程甚至整个测试,至少有两个选项:
- 将Test Action采样器与If Controller结合使用
- 使用Beanshell Sampler或PostProcessor并调用SampleResult类的setStopThread方法。例如,请参阅如何使用BeanShell指南。以供参考:
if (condition){ SampleResult.setStopThread(true); // for Beanshell Sampler prev.setStopThread(true); // for Beanshell Post Processor
}