在Jmeter中设置故障诱饵条件 [英] Setting faillure conditions in Jmeter

查看:203
本文介绍了在Jmeter中设置故障诱饵条件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何根据响应时间在Jmeter中设置条件来确定一个样本成功或失败?

How can I set in Jmeter the conditions to establish that a sample has been a success or a failure according to its response time?

例如,让Jmeter认为响应时间大于10000毫秒的样本是失败的,而响应时间小于10000毫秒的样本是成功的.

For example making Jmeter to consider that a sample with a response time above 10000 milliseconds is a fail and a sample with a response time under 10000 milliseconds is a success.

推荐答案

以下代码将在Beanshell断言中运行.此外,它将中止当前迭代,虚拟用户将从头开始进行下一个迭代

Below code will work in Beanshell Assertion. In addition, it will abort the current iteration and the virtual user will proceed to the next iteration from the beginning

try {
    Long restime = SampleResult.getTime();

    if (restime > 10000) {      
        Failure = true;
        ctx.setRestartNextLoop(true);       
    }
    else    { 
        Failure = false;
        //AssertionResult.setFailure(false);
    }   
}
catch ( Exception ex) {
        Failure = true;
        ctx.setRestartNextLoop(true);       
}

这篇关于在Jmeter中设置故障诱饵条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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