In this section, we will discuss on Assertion in JMeter. Ability to validate test on response of the sampler request sent to server. When you would like to verify expected result and actual result then assertion is the correct option to choose. In JMeter, we can verify the assertion from the Assertion Listener which need to be added in Thread. Assertion is a part of Post Processor.
Below is the list of Assertion present in JMeter.
- BeanShell Assertion
- BSF Assertion
- Compare Assertion
- Duration Assertion
- HTML Assertion
- JSR223 Assertion
- MD5Hex Assertion
- Response Assertion
- Size Assertion
- SMIME Assertion
- XML Assertion
- XML Schema Assertion
- XPath Assertion
Let’s understand the what assertion signifies what.
- BeanShell Assertion : Using Beanshell script to execute customized logic.
- BSF Assertion :
- Compare Assertion: Comparing result between themselves
- Duration Assertion : Verify the response receive within a given elapsed time
- HTML Assertion : verify HTML response by using JTidy
- JSR223 Assertion: Running your own code logic by using JSR223 Script.
- MD5Hex Assertion: If you want to verify the MD5 hash of the response data for static files then MD5Hex is good option.
- Response Assertion: Response Assertion is used to verify the server response is correct or not
- Size Assertion: Verify the size pf the server response with number of bytes.
- SMIME Assertion : Verify the sample result from the Mail Reader Sampler
- XML Assertion: Check the response is a valid XML
- XML Schema Assertion : Verify the SML Schema with XML response.
- XPath Assertion: Tests if a document is well-formed
Generally, there are 4 types of Assertion in JMeter.
- Response Assertion
- Size Assertion
- Duration Assertion
- XML Assertion
- HTML Assertion
Let’s discuss all types of Assertion in details.
Response Assertion:
Response Assertion is used to verify the server response is correct or not. If we click the Facebook link in URL and want to verify the response, then we should use Response Assertion.

Above screenshot is the example of Response Assertion. It has some filed we should aware of. Let’s discuss the significance of each field.
- Name: This field signifies the name of the assertion which will be listed under the Thread. Name field is so crucial if you will be working with a big application having lots of validation and functionalities.
- Comments: Comments field is usually used to give comments to our Assertion. This field is optional.
- Apply to: This field is used to specify that in which sampler the assertion should apply. Whether in Main Sampler or Sub Sampler or both. If we choose Main Sampler only then Assertion should apply to Main Sampler only, not in Sub Sampler.
- Field to Test: This field allow us to specify the field in which the Assertion should apply. E.g. Text Response, Response Code, Response Message Response Header, Request Header, URL Sampler, Document(text). Ignore Status, Request Data etc.
- Pattern Matching: This filed allow us to specify the rule to matching the pattern. E.g. Contains, Matches, Equals, Substring, Not, Or etc.
- Pattern to Test: This field allow us to specify the pattern to verify the response.
Size Assertion:
Size Assertion verify the size of the response. This checks whether the response contains expected number of byte or not. If not, then Assertion will fail.

Above screenshot is the example of Size Assertion. It has some filed we should aware of. Let’s discuss the significance of each field.
- Name : This field signifies the name of the assertion which will be listed under the Thread. Name field is so crucial if you will be working with a big application having lots of validation and functionalities.
- Comments: Comments field is usually used to give comments to our Assertion. This field is optional.
- Apply to: This field is used to specify that in which sampler the assertion should apply. Whether in Main Sampler or Sub Sampler or both. If we choose Main Sampler only then Assertion should apply to Main Sampler only, not in Sub Sampler.
- Response Size Field to Test: This field allow us to specify the field in which the Assertion should apply. E.g. Full Response, Response Headers, Response Body, Response Code, Response Message etc.
- Size to Assert: This field allow us to specify the size to verify the response.
Duration Assertion:
Duration Assertion verify the time constraint used to verify the response. This checks whether the response received within a time duration or not. If not, then Assertion will fail.

Above screenshot is the example of Duration Assertion. It has some filed we should aware of. Let’s discuss the significance of each field.
- Name: This field signifies the name of the assertion which will be listed under the Thread. Name field is so crucial if you will be working with a big application having lots of validation and functionalities.
- Comments: Comments field is usually used to give comments to our Assertion. This field is optional.
- Apply to: This field is used to specify that in which sampler the assertion should apply. Whether in Main Sampler or Sub Sampler or both. If we choose Main Sampler only then Assertion should apply to Main Sampler only, not in Sub Sampler.
- Duration in milliseconds: This field allow us to specify the time duration to verify the response.
XML Assertion:
This Assertion will verify the whether the Server response data comprises to correct XML document or not.

Above screenshot is the example of XML Assertion. It has only 2 field , Name and Comments
- Name: This field signifies the name of the assertion which will be listed under the Thread. Name field is so crucial if you will be working with a big application having lots of validation and functionalities.
- Comments: Comments field is usually used to give comments to our Assertion. This field is optional.
HTML Assertion:
This Assertion will verify the response contains the HTML syntax or not using “HTML syntax checker”. This will fail if this assertion will fail to verify the format of the HTML syntax.

Above screenshot is the example of HTML Assertion. It has some filed we should aware of. Let’s discuss the significance of each field.
- Name: This field signifies the name of the assertion which will be listed under the Thread. Name field is so crucial if you will be working with a big application having lots of validation and functionalities.
- Comments : Comments field is usually used to give comments to our Assertion. This field is optional.
- DocType: DoctType field specifies the format of the Document whether it of below type
- Omit
- Auto
- Strict
- Loose
- Format: This field specifies that on which HTML type this Assertion will be applied. E.g. HTML. XHTMLXML.
- Errors Only: This field will verify only Error and assert only Error in HTML Response.
- Error Threshold: This field will specify the Threshold for the Error.
- Warning Threshold: This field will specify the Threshold for the Warning.
- Write JTidy report to File: This file will be the result file in which log should be tacked.
Now we have got the clear picture on Assertion in JMeter.