Duration Assertion

JMeter – Duration Assertion

When we have an NFR response time and want to pass or fail a sampler or transaction handler based on those numbers, we typically use JMeter’s lifetime assertion function. ‘Apply to’ and ‘duration’ are the only inputs required for this simple assertion element.

How to add ‘Duration Assertion’?

You can follow the below steps:

  1. Select the ‘Sampler’ element whose response duration needs to be validated.
  2. Right-click on the element
  3. Hover the cursor on ‘Add’
  4. Hover the cursor on ‘Assertions
  5. Click ‘Duration Assertions”
JMeter - Duration Assertion

What are the ‘Duration Assertion’ input fields?

There are the following input fields for “Duration Assertion“:

Name: to specify the name of the assertion.

Leave any comment random.

Apply to: Definition of search parameters.

Main sample and subsamples: Use this option if the request is redirected so that the response time is the sum of the response times of the original and redirected requests and can be compared to the expected duration.

primary sample only: When we want to validate only the response time of the primary sample, this option can be chosen.

Subsample Only – This option should be chosen when the request is redirected and response time duration comparison is only required for the subsample (redirect) technique.

Duration to be confirmed: In the “Duration in milliseconds” field, the expected duration of the response time must be entered. This value is compared to the actual duration of the response time and a determination is made. The sampler is logged as failed if the actual duration is longer than the expected duration, and a pass is given if the actual duration is shorter than the expected duration.

Assertion Result

Some Important Guidelines for Duration Assertion

The duration assertion is scoping-compliant, which means that if we add a duration assertion at the transaction level, it will apply to all samples associated with that transaction.

Milliseconds must be used to indicate duration.

Duration values can be parameterized.

In the test plan, you can specify a global duration determination that is valid for all samplers.

Scroll to Top