jmeter 停止当前迭代 [英] jmeter stop current iteration

查看:37
本文介绍了jmeter 停止当前迭代的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我面临以下问题:

我的测试计划中有多个 HTTP 请求.如果失败,我希望每个请求都重复 4 次.我意识到使用 BeanShell 断言,并且它已经工作正常.我的问题是,如果前一个请求失败 5 次,我不希望执行请求,但我也不希望线程结束.

I have multiple HTTP Requests in my testplan. I want every request to be repeated 4 times if they fail. I realized that with a BeanShell Assertion, and its already working fine. My problem is, that I don't want requests to be executed if a previous Request failed 5 times, BUT I also dont want the thread to end.

我只想结束当前的线程迭代,以便线程的下一次迭代可以从第一个请求重新开始(如果要重复该线程).

I just want the current thread iteration to end, so that the next iteration of the thread can start again with the 1st request (if the thread is meant to be repeated).

我如何在 BeanShell 断言中意识到这一点?这只是我希望解决方案具有的代码的简短摘录

How do I realize that within the BeanShell Assertion? Here is just a short extract of my code where i want the solution to have

badResponseCounter 每次失败的请求尝试都会增加,到目前为止这似乎有效.之后,变量被重置.

badResponseCounter is being increased for every failed try of the request, this seems to work so far. Afterwards, the variable gets resetted.

if (badResponseCounter = 5) {
        badResponseCounter = 0;
     // Stop current iteration
    }

我已经检查了 API,提供了 setStopTest() 或 setStopThread() 等方法,但没有用于退出当前迭代.我还需要线程组中的首选项继续",否则整个测试将在 1 个单个请求失败后停止.关于如何做到这一点的任何想法?

I already checked the API, methods like setStopTest() or setStopThread() are given, but nothing for quitting the current iteration. I also need the preference "continue" in the thread group, as otherwise the entire test will stop after 1 single request failed. Any ideas of how to do this?

推荐答案

试试这个.

ctx.setRestartNextLoop(true);

如果线程数为 2,我尝试跳过.我得到了我预期的以下结果(它没有调用 b-2).它也不会杀死线程.

if the thread number is 2, i tried to skip. I get the below result as i expected (it does not call b-2). It does not kill the thread either.

这篇关于jmeter 停止当前迭代的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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