Response assertion inwards jmeter is almost of import chemical ingredient equally it helps you lot to assert the reply of asking inwards your software charge examine plan. It volition exhibit asking upshot failed if reply of asking is non equally expected in addition to exhibit exceed if response of asking is equally expected. So you lot tin verify your software charge examine upshot using the reply assertion. In this section, We volition larn how to assert reply code of asking using reply assertion.
Add Response Assertion In Your software charge examine plan
You tin add together assertion nether asking or parallel to request. To add together reply assertion nether request,
- Right click on asking -> Select Add -> Assertions -> Response Assertion equally shown inwards bellow given image.
It volition add together reply assertion nether request.
Example : Assert Response Code Using Response Assertion
I accept created real uncomplicated instance to demonstrate you lot how reply assertion genuinely works. We volition assert reply code of software spider web application's asking inwards this example. If you lot know, reply code 200 represents your HTTP request has succeeded.
In this example, We volition assert for reply code 200 using reply assertion. We volition banking concern tally reply code for bellow given two requests. One for valid in addition to i for invalid.
- newtours.demoaut.com(Valid URL which returns reply code : 200)
- newtours1.demoaut.com(Invalid URL which returns reply code : Non HTTP reply code)
Also added Response assertion nether both requests amongst same parameter configuration. Here our aim is to assert reply code 200 of HTTP asking hence assertion parameters configuration is equally bellow.
Assertion parameters config for both request's reply assertion :
- Apply To = Main Sample only.
- Response Field to Test = Response Code.
- Pattern Matching Rules = Contains.
- Pattern To Test = 200.
Note : In our instance software charge examine plan, Both reply assertions has same inwards a higher house parameter configuration.
Above configuration of reply assertion volition banking concern tally reply code of HTTP requests. If reply code contains 200 hence volition testament survive passed. Else it volition exhibit upshot equally fail.
I accept added Assertion Results listener nether both requests equally shown inwards in a higher house icon to persuasion assertions upshot on examine execution.
Thread grouping configuration is equally bellow.
Now run inwards a higher house software charge examine plan. Assertion results of both assertions volition aspect similar bellow.
Assertion Result of 1st HTTP request : Not display whatever fault inwards assertion upshot of of 1st HTTP request. That agency HTTP request's reply code is 200 equally expected.
Assertion Result of 2d HTTP request : Display fault inwards assertion upshot of 2d HTTP request. That agency HTTP request's reply code is non 200 hence assertion is failed.
Also persuasion upshot tree of both requests volition looks similar bellow. You tin encounter that reply code for 1st asking is 200 hence it is pass. But reply code for 2d asking is Non HTTP reply code hence it is failed.
This way you lot tin assert reply code of whatever HTTP asking of your software charge examine innovation equally per your requirement.