Jmeter will help you to create Performance script which are similar to real user but how to validate the response what we received from is valid, To validate the response from server Jmeter has a feature of Assertions. we have different types of assertions like Size Assertion,Bean Shell Assertion, JSR223 Assertion, Response Assertion, XPath Assertion, etc..

In this tutorial we will see the how to use Size Assertion to manage assertions for a Jmeter sampler

When to use Size Assertion ?

  • In a scenario like you have a file download or some binary data getting from server. We will use Size assertion for the request which is getting downloading file

How to use Size Assertion ?

  • Size assertion will be in Assertions in Jmeter
  • To add size assertion we need to right click on the request -> Assertions –> Size assertion 

Below screenshot will give you idea

adding size assertion

In size assertion we have multiple options like you want compare size of only response headers / response body or complete response which includes response header & response body /Response message /Response code

below screenshot will show you the options

size assertion for response body response header,response code or message

 

Types of Comparison of  Size assertion :

we have multiple comparison type like Equals To, Less Than Equal To, Greater Than Equal To, not Equal To, Greater than, Less than

  • ==
  • >=
  • <=
  • !=
  • >
  • <

If your response body size is 100 KB & it may vary for user to user, Min will be 100 KB, If a request is valid and getting min response size is 100 KB then we can use 100 <= 

Note : Jmeter will take the response size in Bytes if you response size is 1 KB after converting into Bytes it will be 1000 bytes we need to use 1000 in size assertion like below

Size assertion example in jmeter

Thanks

Size assertion in Jmeter

Leave a Reply

Your email address will not be published. Required fields are marked *