JMeter - 从 BeanShell 预处理器中停止线程

JMeter - Stop Thread from within a BeanShell PreProcessor

是否有可能停止线程,或从 BeanShell 预处理器 中强制失败?我尝试从 ThreadGroup Class 和其他几个访问 "stop()" function/method ,但是我'我不确定我做对了还是可能。

我想强制我的测试在我的 BeanShell 预处理器 中停止,如果我的脚本中的这个特定的 if 语句结果为 TRUE...这可能吗?我确实阅读了一些 "Failure" 和 "FailureMessage" 函数,但不确定使用这些函数的最终结果是什么。

如有任何想法或建议,我们将不胜感激!

提前致谢,
马特

在 beanshell 预处理器中,你可以试试这个:

org.apache.jmeter.engine.StandardJMeterEngine.stopThread(Thread.currentThread().getName()); 

在 beanshell 中 post 处理器:

if (condition) prev.setStopThread(true);

不过,如果您可以用 if-controller 来表达您的条件,我更愿意使用 Test Action