Friday, April 20, 2012

jmeter: adding assertions to validate correct response

During my test execution I noticed that some responses are getting the error page, for the jmeter is was http 200, so it marked the request as passed, this is not correct, this request should be failing, so I created assertion rule to identify these errors

In my case the error page has it’s own URL, so I added response assertion to check URL sampled not to contain “error”, steps to do so:

Right click on the thread group or the recording controller

Select add –> Assertions –> Response Assertions


Fill the Response Assertion properties:

Apply to: Main samples and sub samples (usually the error page comes as a sub page from the requested page)

Response Field to Test: URL Sampled (In my case the error is identified by the URL of the error page, in other cases the error can be a frame inside the response)

Pattern Matching Rules: Contains, make sure not is checked (This means I am asserting that my response URL is not the error URL)

Pattern to Test: error (in my case the URL to error contained the word error, in other cases it could be a specific text message inside the response)


Adding the Assertion as above, while running, if any sub sample was the error page, it was marked as failed