How to use assertions in JMeter

Assertion in JMeter is used to validate response of the request. You can use them to run against a sample to ensure returned values match expected results.Following are some commonly used assertion in JMeter:

1. Response Assertion
2. Duration Assertion
3. Size Assertion
4. XML Assertion
5. HTML Assertion

All assertions consume system resources like memory and CPU, it may adversely affect the performance values. Response Assertion and Duration Assertion are preferable choice as it consumes very less system  resources. Here we're talking about Response Assertion. Lets look into its details

Response Assertion
The most commonly used assertion is the Response Assertion. It checks whether web response contains, matches, or equals a specified pattern.Response Assertion can be added in following way Thread Group >> Assertions >> Response Assertion. We can add Response Assertion in parameterization and lets verify the url is valid or not. Select Response Code radio button and enter the web response to be verified as 200, refer below figure

jmeter-response-assertion

To verify the assertions results, we need to add Assertions Results in listener. It can add in a following way, Thread Group >> Listener >> Assertion Results. All requirements have been added and lets click on the green button and verify the results

jmeter-assertions-execution

Previous Post Next Post