JMeter - 从 BeanShell 预处理器中停止线程 [英] JMeter - Stop Thread from within a BeanShell PreProcessor
问题描述
是否可以在 BeanShell 预处理器中停止线程或强制失败?我尝试从 ThreadGroup 类和其他几个类访问 "stop()" 函数/方法,但我不确定我做得对,或者它是否正确可能.
Is it possible to stop a Thread, or force a failure from within a BeanShell PreProcessor? I tried accessing the "stop()" function/method from the ThreadGroup Class and a few others, but I'm not sure I'm doing it right or if its possible.
我想强制我的测试在我的 BeanShell PreProcessor 内停止,如果我的脚本中的这个特定 if 语句导致 TRUE...这可能吗?我确实阅读了一些Failure"和FailureMessage"函数,但不确定使用这些函数的最终结果是什么.
I wanted to force my Test to stop inside my BeanShell PreProcessor if this one particular if statement inside my script resulted in TRUE... Is this possible? I did read a little of the "Failure" and "FailureMessage" functions, but wasn't sure the end result of using those was.
任何想法或建议将不胜感激!
Any thoughts or suggestion would be greatly appreciated!
提前致谢,
马特
Thanks in Advance,
Matt
推荐答案
在 beanshell 预处理器中,你可以试试这个:
In a beanshell pre processor, you could try this:
org.apache.jmeter.engine.StandardJMeterEngine.stopThread(Thread.currentThread().getName());
在豆壳后处理器中:
if (condition) prev.setStopThread(true);
如果你可以用 if-controller
来表达你的条件,我更愿意使用 测试操作.
If you can express your condition as an if-controller
though, I would prefer to use a Test Action.
这篇关于JMeter - 从 BeanShell 预处理器中停止线程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!