During the test I've got 3 types of exception from the same requests (or may be from different also).
I want to sort and to group them in any kind of view to see how many each type of exceptions are there.
I can add response assertion for each type of exception in the response, but how can I group them in report?
In the ideal case I would like to get:
Any ideas how to do that?
I think of at least 2 ways:
Use Sample Variables property like:
Exception
Add the next line to user.properties file:
sample_variables=Exception
Next time you run your test in command-line non-GUI mode like:
jmeter -n -t test.jmx -l result.csv
you will see an extra column called Exception
having the value of the exception. Now you should be able to use LibreOffice Calc or Microsoft Excel to calculate the percentages for a certain exception
You can use JSR223 Listener in order to rename the sampler according to the Exception occurred, the relevant code would be something like:
if (!prev.isSuccessful()) {
prev.setSampleLabel((prev.getResponseDataAsString() =~ "(\\w+)Exception")[0][1] as String)
}
where prev
is a shorthand for the parent SampleResult
The above code will extract the exception type from the response (if the sampler is failed and the exception type is there) and rename the sampler according to the exception type.
You can find more information on Groovy scripting in the Apache Groovy - Why and How You Should Use It article