JMeter-从BeanShell预处理器中停止线程 [英] JMeter - Stop Thread from within a BeanShell PreProcessor

查看:878
本文介绍了JMeter-从BeanShell预处理器中停止线程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在 BeanShell PreProcessor 中停止线程或强制失败?我尝试从 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.

如果脚本中的这一特定if语句导致TRUE,我想强迫我的Test停止在 BeanShell PreProcessor 内部.这可能吗?我确实阅读了一些"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()); 

在beanshell后处理器中:

In a beanshell post processor:

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆