In JMeter, Duration Assertion is mainly used when we have response time NFR and on the basis of those figures, we want to make a sampler or transaction controller pass or fail. It is a simple assertion element where we just need to provide ‘apply to’ and ‘duration’ input.
How to add ‘Duration Assertion’?
You can follow the below steps:
- Select the ‘Sampler’ element whose response duration needs to be validated.
- Right-click on the element
- Hover the cursor on ‘Add’
- Hover the cursor on ‘Assertions‘
- Click ‘Duration Assertions”
What are the input fields of ‘Duration Assertion’?
‘Duration Assertion’ has the following input fields:
- 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 time duration will be the sum of both main and re-directed request response time and can be compared with the expected duration.
- Main sample only: This option can be selected when we want to validate the response time of the main sample only.
- Sub-samples only: When the request is re-directed and the response time duration comparison is needed only for the sub-sample (re-directed) method then this option needs to be selected.
- Duration to Assert: The expected response time duration needs to be provided in the ‘Duration in milliseconds’ field which will be compared with the actual response time duration and a decision will be made. When the actual duration is more than the expected duration then the sampler will be marked as failed whereas when the actual duration is less than the expected duration then the result will be treated as pass.
Some Key Rules related to Duration Assertion:
- Duration assertion follows scope policy means if we add duration assertion at the transaction level then the assertion is applicable to all the samplers under the same transaction.
- Duration should be given in milliseconds.
- The duration value can be parameterized.
- You can define Global Duration Assertion under the test plan which will be applicable to all the samplers.
You may be interested:
- Performance Testing Tutorial
- Performance Engineering Tutorial
- Micro Focus LoadRunner Tutorial
- NeoLoad Tutorial