The assertion in JMeter is used to validate the response of the request, that you have sent to the server. The assertion is a process where you verify the expected result with the actual result of the request at run time. If you need to apply assertion on a particular Sampler, then add it as a child of that Sampler.
Response Assertion – It facilitates the user by comparing the server response against a string pattern to check that the result is as expected.
Duration Assertion – Duration assertion is used to verify how long a request takes to complete. The Duration measured in milliseconds, and, if any request lasts longer than the value specified, the sample is marked as failed.
Size Assertion – It is to test that each response coming from server holds the expected number of bytes. It facilitates the user to specify the size.
XML Assertion – The XML Assertion checks that the returned response body is XML-compliant. Only the syntax is checked. Any external resources are neither downloaded nor validated.
HTML Assertion – The HTML Assertion checks that the response HTML syntax is a well-formed HTML/XHTML/XML document. So it is handy if your Web application or site requires zero HTML validation errors.
Beanshell Assertion:
String path = SampleResult.getURL().getPath();
if (!path.contains(“blazemeter”)) {
Failure = true;
FailureMessage = “URL Path: didn’t contain ‘blazemeter'” + System.getProperty(“line.separator”) + “URL Path detected: ” + path;
}
Compare Assertion:
The Compare Assertion checks the response content or confirms that the response time of all samplers under the assertion scope is equal.