When an request error occurs during a performance test, you usually want to have more details on the request and response to understand root cause of the issue and provide more details to the development team so that they are able to reproduce and fix the issue.
Configuring your test plan
To save request and response details in JMeter only when an error occurs, you can use the combination of a “Response Assertion” and a Listener “Simple Data Writer“
This component will help you defined what is an “Error” in your test case.
It can be added by “Add > Assertions > Response Assertion”.
By default JMeter will consider any HTTP response code >= 400 as an error, in this case you have nothing to do.
But usually, you’ll want to have additional checks on a response by checking the presence of a text in the response for example.
Read this blog for more details on this component.
Saving errors to a file
This listener allows you to save the results of your test to a file. You can add this listener by right-clicking on the “Thread Group” or “Test Plan” and selecting “Add > Listener > Simple Data Writer”.
In our case, we only want to save Errors so we check “Errors” checkbox:
We then set “Filename” field to:
Finally, to have the full details of HTTP request and response, we click on “Configure” button and check the fields we want so that we have this:
Reading error file
Then you can run your test, you will have an additional output file called “errors.xml” that will contain the full details of requests that failed.
You can read this file using JMeter, by adding a “View Results Tree” and clicking on “Browse” button, it will show you all elements of a request / response including headers for HTTP for example:
- Ubik Load Pack is a set of Enterprise Grade plugins for Apache JMeter.
- We’re strong contributors to JMeter and its eco-system
- We provide professional services for Load Testing
- Free trial is available on https://ubikloadpack.com/tryout.php
- Using CSV data in JMeter 2 March 2023
- How to save request and response details in JMeter only when an error occurs 27 February 2023
- Using a Property in JMeter to reference environment dependent data 27 February 2023