Size Assertion in JMeter: JMeter will help you to create Performance scripts that are similar to real users but how to validate the response that we received is valid, To validate the response from the 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 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 the 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 

The below screenshot will give you an idea

adding size assertion

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

The 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 types 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 from 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 your 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

JSON Assertion in JMeter – An Ultimate Guide

Thanks.

Size Assertion in JMeter

Leave a Reply

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