在JMeter中有条件地停止用户线程 [英] Stopping a user thread conditionally in JMeter

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

问题描述

我有一个JMeter脚本正在为x个用户运行.我想有条件地关闭while控制器中的用户线程.例如,如果我的while控制器退出了用户线程,则需要停止线程.是否有可能?很抱歉,如果这是重复的问题还是一个愚蠢的问题.

I have a JMeter script running for x number of users. I want to conditionally close a user thread in a while controller. For example, if my while controller exits for a user thread, I need to stop the thread. Is it possible? Sorry if this is duplicate or a dumb question.

推荐答案

关于如何有条件地停止测试线程甚至整个测试,至少有两个选项:

There are at least 2 options on how you can conditionally stop test thread or even the whole test:

  1. 结合使用测试操作采样器和 setStopThread 方法SampleResult类.例如,请参见如何使用BeanShell 指南.供参考:
  1. Use Test Action sampler in combination with If Controller
  2. Use Beanshell Sampler or PostProcessor and invoke setStopThread method of SampleResult class. See How to use BeanShell guide for example. For reference:

if (condition){
    SampleResult.setStopThread(true); // for Beanshell Sampler
    prev.setStopThread(true); // for Beanshell Post Processor
}

这篇关于在JMeter中有条件地停止用户线程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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