JMeter Assertion Examples

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: /

Assertions in JMeter examples

Assertion helps to confirm that server under test returns the expected result. Assertions allows us to define the pass/fail criteria for application under test. We can configure what kind of assertions is active for every test plan.

Example, if a web response doesn't contain an expected expression, it would be considered as a failure.

Assertions can be added to any controller in a test plan by simply right-click on the controller and add an assertion. Assertions can be applied to a main sample and its sub-samples, or only to sub-samples.