Size Assertion checks the response length to see if it's equal/not equal/greater/less than the expected size in bytes. It can be applied to:
- A full response (body and headers)
- Response headers
- Response body
- Response code
- Response message
- The easiest way to check the response size is through the View Results Tree Listener.
- Here is an example of the sample output: For the Full Response assertion, it should be testing “=” comparison type and 1591 bytes.
- For the Response Body - 1270 bytes
For the Response Headers - 321 bytes
The Following Example Demonstrates Size Assertion
- Add Size Assertion to the authenticate-81 request.
- The size assertion validates how much the size in bytes the response is generated.
- Click on the View Results Tree and then click on the Authenticate-81 and then open the Sampler Result, you will find the total bytes of that request.
- In the above image, you will see the size in bytes are 3846, which means the 3846 bytes response has been generated for the authenticate-81 request.
- The total size in bytes is required because we need to know at a point in time if authenticate-81 can handle 100 requests, which means
100*3846=384600 bytes are written by the server in one single second. this is the throughput parameter.
- It is like how many processes have been happened from the server-side.
- Sometimes this number goes down if you have a heavy load on the application and it is not able to load full-size bytes.
- Now, go to the Size Assertion and then click on it.
- Enter the
3000 as an average and select the
Greater Than(>) symbol.
- Now run the Test Plan, the Test Plan will execute without any error.
- That means when we are checking Full Response the Size which is return by the response should be less than the total size but it can be greater than the mentioned size.
- If it is greater than the total size in bytes then the JMeter will throw an error.