Setting faillure conditions in Jmeter

2019-06-03 01:13发布

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?

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.

2条回答
smile是对你的礼貌
2楼-- · 2019-06-03 01:29

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);       
}
查看更多
老娘就宠你
3楼-- · 2019-06-03 01:50

Add Duration Assertion as a child to the sampler in which you want to assert the response times.

In Duration in milliseconds field, add value 10000.

查看更多
登录 后发表回答