Setting faillure conditions in Jmeter

∥☆過路亽.° 提交于 2019-12-23 03:36:04

问题


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.


回答1:


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.




回答2:


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);       
}


来源:https://stackoverflow.com/questions/42092776/setting-faillure-conditions-in-jmeter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!