SUBSCRIBE HERE TO GET POST UPDATES VIA EMAIL :

Delivered by FeedBurner

JMeter - Size Assertion With Example

Size assertion in jmeter software load test plan is useful to assert the byte size of request response. You can use different conditions in response assertion like equal to, not equal to, greater than, less than, greater than or equal to, less than or equal to a given number of bytes for response. Here we will learn how to use size assertion in your jmeter software load test plan to assert size of response.

Add Size Assertion In Test Plan
Practically we need to add size assertion under request. To add size assertion under request,
  • Right click on request -> Add -> Select Assertions -> Size Assertion. See bellow given image.

It will add size assertion under request.

Example : Using Size Assertion In Jmeter Test Plan
I have prepared sample jmeter software load test example to show you how actually size assertion works. I have added 2 HTTP requests with size assertion as shown in bellow image.


Size assertion configuration for both requests is as bellow.


1st HTTP request's size assertion config

  • Apply To : Main Sample Only
  • Response Size Field To Test : Full Response
  • Size In bytes : 5000
  • Type Of Comparison : >=(Greater than or equal to)

2nd HTTP request's size assertion config
  • Apply To : Main Sample Only
  • Response Size Field To Test : Full Response
  • Size In bytes : 5000
  • Type Of Comparison : <=(Less than or equal to)
Only difference in both assertion's config is type of comparison.

Both HTTP request's config is same as bellow.


When you run above test plan, Result will looks like bellow.


In result you can see that 1st request is pass that means request response size is greater than or equal to 5000 bytes which we have set in 1st request's size assertion. Size assertion of 2nd request is fail and display Assertion failure message: "The result was the wrong size: It was 10,256 bytes, but should have been less than or equal to 5,000 bytes."

This way you can use size assertion in your jmeter software load test plan to assert size of request response.

No comments:

Post a Comment