Quality Testing

Quality is delighting customers

Jmeter :capture assertion failure messages in benashell

I am writing plugin for jmeter.

How can I access jmeter assertion failure messages or result details in a benashell /or post processor bean shell so that I can write my own report for API testing using jmeter?

Views: 52

Reply to This

Replies to This Discussion

There is prev shorthand which can be used in the JSR223 Listener in order to access parent SampleResult which in its turn provides getFirstAssertionFailureMessage() function which seems to be exactly what you're looking for 

So you can access the failure message as simple as:

String failureMessage = prev.getFirstAssertionFailureMessage();

Demo:

If you prefer Beanshell - you can use the same code in the Beanshell Listener, however be aware that since JMeter 3.1 it's recommended to use JSR223 Test Elements and G... for any form of scripting, the reasons are in:

Dear friend 

I am getting some error now, but I need all the assertion errors to be captured and later i will write one report and make jar.

Do you know how to capture all the assertion errors ?

Thanks in advance for help.

JSR223 Listener obeys JMeter Scoping Rules so if you put it at the same level as your Samplers - it will be applied to all of them. You can write the messages into a file or whatever. 

Also be aware that JMeter automatically saves assertion failure messages into .jtl results file, if it doesn't - you can add the next line to user.properties

jmeter.save.saveservice.assertion_results_failure_message=true

JMeter restart will be required to pick the properties up. 

 

Thanks very much for elaborating.

Actually I need to write a custom report with pass/fail, assertion errors.

For this I need to get the assertion errors in any java object in bean shell. From there I will arite a report using java. I will Can I get that way?

@Dimitri - Thanks for your details answer.

RSS

TTWT Magazine


Advertisement

Advertisement

Advertisement

Advertisement

© 2019   Created by Quality Testing.   Powered by

Badges  |  Report an Issue  |  Terms of Service