RSS

JMeter how to NOT fail 500 Internal Server Errors

07 Mar

Access and modify SampleResult – to change the status from “FAIL” to “PASS” if the code is 500 – from your BeanShell Assertion / BSF Assertion or use BeanShell PostProcessor / BSF PostProcessor instead – they all have access to SampleResult Object.

1. BeanShell Assertion

if (ResponseCode.equals("500") == true) { 
    SampleResult.setResponseOK();  

    /* the same is 
    SampleResult.setSuccessful(true);
    SampleResult.setResponseCodeOK();
    SampleResult.setResponseMessageOK();
    */
}

2. BeanShell PostProcessor
Use prev instead – to access SampleResult object of the sampler to which one post-processor is attached:

if (prev.getResponseCode().equals("500") == true) { 
    prev.setResponseOK();  

    /* the same is 
    prev.setSuccessful(true);
    prev.setResponseCodeOK();
    prev.setResponseMessageOK();
    */
}
Advertisements
 
Leave a comment

Posted by on 07/03/2016 in Jmeter

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

 
%d bloggers like this: