I am using 'BeanShell PostProcessor' to get the request and response data for generating the result file But I am not able to get the asseration result form Response assertion, Here I have added response assertion inside of sampler, i want to print that success message in logs
whether it is failed/pass like: Success message/Assertion result - True/False Please find the screen shot: I will be able to print the all data in excel except 'Success Message(pass/fail)(true/false) Please find the screen shot:
As per JMeter Test Elements Execution Order :
You cannot get AssertionResult from the PostProcessor as the Assertion hasn't been executed yet, you need to switch to a Listener .
Also, forget about Beanshell , since JMeter 3.1 it's recommended to use JSR223 Test Elements and Groovy language , the relevant Groovy code to print Assertion results and failure messages to the jmeter.log file would be something like:
prev.getAssertionResults().each { assertionResult ->
log.info('Failure: ' + assertionResult.isFailure())
log.info('Failure message: ' + assertionResult.getFailureMessage())
}
Demo:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.