I am working on Webservice Testing using Jmeter.I am using Beanshell Assertion In this I am trying to display the Response Code and Response Message but the problem is when the Request Fails I am unable to get the response Code|Message displayed on my jmeter log file.In case If I get the Proper response I am getting the Response Code|Message Properly.Is there any solution to get the Response Code|Message when the Request Fails in jmeter BeanShell Assertion
Perhaps something is wrong with your Beanshell code as Beanshell Assertion should normally handle parent sampler failure
The code which produced these log lines looks as simple as:
StringBuilder sb = new StringBuilder();
sb.append("Sampler: ");
sb.append(SampleResult.getSampleLabel()).append(" ");
sb.append("Successful: ");
sb.append(SampleResult.isSuccessful()).append(" ");
sb.append("Code: ");
sb.append(ResponseCode).append(" ");
sb.append("Message: ");
sb.append(ResponseMessage);
log.info(sb.toString());
Few tips:
debug();
statement as 1st line of your Beanshell Assertion and inspect STDOUT for detailsSurround your code in try/catch block and in the catch block print exception to jmeter.log file as
try {
//your Beanshell Assertion code here
}
catch (Throwable ex) {
log.error("Something went wrong", ex)
}