i need to write a Assertion error, assertion failure and Assertion failure message(example data below in the pic) to a csv file. What is the best way to do this? Is there a possibility to create a JSR223 Sampler to read assertion messages from all http requests at once and save that to csv file? Built-in saving to file does not meet requirements.
Asked
Active
Viewed 303 times
1 Answers
0
JSR223 Sampler will only have access to the previous sampler result, I would recommend using JSR223 Listener and the following code:
vars.put('failureMessage', prev.getAssertionResults().find { assertionResult -> assertionResult.isFailure() }.getFailureMessage())
the code will extract the failure message from the first assertion
then you need to declare Sample Variables property in user.properties file like:
sample_variables=failureMessage
and finally the variable can be written to a file using Flexible File Writer listener (this guy can be installed using JMeter Plugins Manager)

Dmitri T
- 159,985
- 5
- 83
- 133
-
thank you! I was able to write that first assertion failureMessage to the file. But do you have any solution how to write all failureMessages? From all assertions and how to list from which sampler this is – holgar Mar 11 '22 at 13:02