JMeter how to NOT fail 500 Internal Server Errors

前端 未结 4 1967
梦如初夏
梦如初夏 2020-12-08 00:47

I am using JMeter as a unit test tool, in parameterised calls where I expect some of the responses to be 500 internal server errors. I am using BeanShell Assertions to chec

4条回答
  •  清歌不尽
    2020-12-08 01:21

    Using a BeanShell assertion, force the HTTP Sampler to pass and then pass/fail on a regular Beanshell assertion statement instead:

    if (ResponseCode.equals("500") == true) { 
        SampleResult.setResponseOK();  
    
        /* the same is 
        SampleResult.setSuccessful(true);
        SampleResult.setResponseCodeOK();
        SampleResult.setResponseMessageOK();
        */
    }
    String path = SampleResult.getURL().getPath();
    if (!path.contains("anerror")) {
        Failure = true;
        FailureMessage = "URL Path: didn't contain \"anerror\"" +
            System.getProperty("line.separator") + "URL Path detected: " + path;
    }
    

提交回复
热议问题