JMeter Duration Assertion with Example

This assertion tests that each response was received within a given amount of time. Any response that takes longer than the given number of time (milliseconds) specified by the user is marked as a failed response.

Let us look into an example :

Step 1. Right Click Test Plan > Add > Threads(Users) > Thread Group

Step 2. Thread Group > Add > Config Element > HTTP Request Default
Set Server Name as:

Step 3. Thread Group>Add > Sampler > HTTP Request (Change name to Google Home Page)
Set Path as: /

Step 4. HTTP Request (Google Home Page) > Add > Assertions > Duration Assertion
Duration in Milliseconds - The maximum number of milliseconds each response is allowed before being marked as failed.

Set Duration in Milliseconds value as '1000'

Apache JMeter Timer

In the above example, if JMeter receives response within the specified time '1000' milliseconds then the result will be pass, else failed.

Now lets us decrease the value of Duration in Milliseconds value as '10'.

Apache JMeter Timer

To view the Results, let us add Listener - > View Results in Table to check the time took to load the page.

Now run script again to expect the response as failed. When the Duration Assertion Fails, it will display message as 'Duration Assertion : The operation lasted too long: It took 296 milliseconds, but should not have lasted longer than 10 milliseconds.'

You can now check the sample time that took to load the Page

Apache JMeter Timer

Now Check the Assertion Results with failed message

Apache JMeter Timer

We can add Duration Response to Main Samplers or Sub Samplers. Please fell free to comment your queries on Duration Assertion.

JMeter Tutorials: 


I was under the assumption that Jmeter will fail the sample and will stop the thread if response time is taking longer than the expected time. But seems like thats not the case. Do you know if there is a way to fail and stop the thread as soon as any sample crosses the threshold limit defined by user?

Add new comment

This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.