Since performance testing falls under the non-functional testing category but getting a correct functional response is always the first priority. All the performance testing tools have such a feature to validate the response coming from the server and raise a warning or error when the validation fails. JMeter also has a special element called ‘Assertion’ to validate the response on the basis of pre-defined conditions. Based on the validation result, it makes a decision to pass or fail the sampler. Basically, the assertion elements are a part of the post-processor family because they execute after getting the response from the server and then compare the expected result with the actual result.
Assertion elements are scope specific. They have local as well as global scope, depending on the place where they get added. If you add an assertion as a child element of a test plan then its scope becomes global and this assertion will validate all the requests. On the other hand, if you add it under a sampler, only that particular sampler’s response will be validated.
You can view assertion results by adding ‘Assertion Listener’ to the Thread Group.
Possible Parent element(s) of Assertion:
You can add an Assertion under the following elements:
- Test Plan
- Thread Group
- Test Fragment
- Sampler
- Logic Controller
- Non-Test Element
Possible Child Element(s):
- NA
You can not add any element under an ‘Assertion’ element. Hence it does not have any child element.
List of Assertion elements in JMeter:
- Response Assertion
- Duration Assertion
- Size Assertion
- XML Assertion
- BeanShell Assertion
- MD5Hex Assertion
- HTML Assertion
- XPath Assertion
- XPath2 Assertion
- XML Schema Assertion
- JSR223 Assertion
- Compare Assertion
- SMIME Assertion
- JSON Assertion
- JSON JMESPath Assertion
You may be interested:
- Performance Testing Tutorial
- Performance Engineering Tutorial
- Micro Focus LoadRunner Tutorial
- NeoLoad Tutorial