How To Use Assertions In JMeter

Posted By : Palak Tiwari | 30-Jan-2018

An assertion is used to validate response to the request, that has been sent to the server. In this a process, we are verifying the expected result with the actual result of the request at a runtime. Application of assertion on a particular Sampler is done by adding it as a child of that Sampler.

 

We can see assertion result by adding “Assertion Listener” to the Thread Group. The result of failed assertions also be displayed in other listeners as well.

 

1:  Response Assertion: 
This Assertion basically used to add and compare pattern strings against all values of the server response.Here we can verify this response by using Response Assertion. 

Response Entities that can be checked include:

a) Text response -It is for the response that can be displayed in the browser.
b) Response Headers - It is used against Response Headers to see either specific HTTP header is present or not present.
c) Response Message - It verifies that the response message is same as expected or not. 

 

2:  Size Assertion:
This assertion is used to verify either the server response contains expected number of Bytes or not.


3:  Duration Assertion:
It is used to verify that server response is either received within a specified time constraint or not.The sample request will be marked as failed if a response comes in longer time duration.

 

4:  XML Assertion:
This assertion is used to verify either server response data comprises of an expected XML document or not.

 

5:  HTML Assertion:
It is used to verify that the response contains correct HTML syntax or not using JTidy (HTML Syntax Checker).A test will fail in case of improper HTML syntax response.

 

How can we select good or perfect assertions?

For all who work with JMeter and performance tests, we know the importance of adding validations to all HTTP Requests. Validations basically not only confirm that the server is responding as expected, but it also verifies that the script we are developing is performed as expected or not.It will simulate the user behavior as it was designed.

THANKS

Related Tags

About Author

Author Image
Palak Tiwari

Software tester with good knowledge testing skills in various areas. She believes in continuous learning .

Request for Proposal

Name is required

Comment is required

Sending message..