Pages

Monday 30 January 2017

JMeter - Assertions - "Size Assertion"

Size Assertion is mainly used when we want to validate the size of the full response or some part of the response like header, code etc. This assertion helps to identify the throughput related issue. A simple scenario where you can add size assertion is a file downloading scenario.
How to add "Size Assertion" element?
You can follow the below steps:
1. Select "Sampler" node whose response duration needs to be validated.
2. Right-click on the node
3. Mouse hovers "Add"
4. Mouse hovers "Assertions"
5. Click "Size Assertion"

How to remove "Size Assertion" element?
You can follow the below steps:
1. Select "Size Assertion" node
2. Right click on "Duration Assertion" node
3. Click "Remove" (Mouse) or "Delete" button from the keyboard
4. Click "Yes"    

What are the attributes of "Size Assertion" element?

"Size Assertion" has the following attributes:
  • Name: To provide the name of the assertion.
  • Comments: To provide arbitrary comments (if any)
  • Apply to: To define the search scope. 
  •  Main sample and sub-samples: In case, the request is redirected then use this option, so that the response will be the sum of both main and re-directed request response size and can be compared with the expected response size.
  • Main sample only: This option can be selected when we want to validate the response size of main sample only.
  • Sub-samples only: When request is re-directed and the response size comparison is needed only for sub-sample (re-directed) method then this option needs to be selected.
  • JMeter Variable Name to use: To validate the size of JMeter variable.  
  • Response Size Field to Test: This option is used to specify the part of response whose size needs to be validated. 
  • Full Response: It includes both response header as well as response body size and the sum is compared with expected size figure given in 'Size to Assert' field. 
  • Response Hearders: Only the size of response header is compared with the given size. 
  • Response Code: The size of the response code (around 3 bytes) is compared with the given size assertion.
  • Response Message: The given size asserion is compared with response message size.
  • Size to Assert: The expected size of the response needs to be provided in the 'Size in bytes' field which is compared with the actual response size using given condition in 'Types of Comparison' field.
  • Types of Comparison:  JMeter provides all the possible comparison method like equal to (=), not equal to (!=), greater than (>), less than (<), greater than or equal to (>=) and less than or equal to (<=) to compare the actual and expected response size. 
Some Key Rules related to Size Assertion:
1. Size assertion follows scope policy means if we add size assertion at transaction level then the assertion is applicable to all the samplers under the same transaction. 
2. Expected size must be given in bytes.
3. Expected size value can be parametrized.
4. You can define Global Size Assertion under the test plan which will be applicable to all the samplers.    
  
Next Topic:
Apache JMeter - Assertion - "XML Assertion" Element

Previous Topic:

Apache JMeter - Assertion - "Duration Assertions" Element

Related Topics:


  

No comments:

Post a Comment