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

Mat*_*att 5 jmeter beanshell

是否可以在BeanShell PreProcessor 中停止线程或强制失败?我尝试从ThreadGroup类和其他一些类访问“stop()”函数/方法,但我不确定我做得对,或者是否可能。

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

任何想法或建议将不胜感激!

提前致谢,
马特

RaG*_*aGe 5

在 beanshell 预处理器中,您可以尝试以下操作:

org.apache.jmeter.engine.StandardJMeterEngine.stopThread(Thread.currentThread().getName()); 
Run Code Online (Sandbox Code Playgroud)

在 beanshell 后处理器中:

if (condition) prev.setStopThread(true);
Run Code Online (Sandbox Code Playgroud)

如果您可以将您的条件表达为if-controller虽然,我更愿意使用Test Action