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

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

问题描述

我有一个为 x 个用户运行的 JMeter 脚本.我想有条件地关闭一个 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.

推荐答案

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

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

  1. 结合使用 Test Action 采样器和 如果控制器
  2. 使用 Beanshell Sampler 或 PostProcessor 并调用 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天全站免登陆