The main goal for any performance test script simply is to work , but is this enough? I mean is it enough that your script has no errors ?
No errors do not mean that your script is working flawlessly , you may get a 200 response code but the script functionality is not working and in this case all your results are not correct.
The process of checking if you receive the correct response is called Validation.
In this article I will demonstrate the validation process using JMeter as one of the performance testing tools that is widely being used.
How to use validations in JMeter
In JMeter context menu we have a whole section called Assertions as in the image below
As you can see above there are lots of assertions available to use but we will focus on one particular called “Response Assertion”
Before we start to dig more deeper let’s have an example to show when the response code doesn’t mean that the script is working correctly.
Our script should do the following :
1- Open “demo.testfire.net”
2- Open the Login page
3- Do the Login with the credentials (admin/admin)
In the following 2 screen shots we will Show that having a success repose code doesn’t mean that the scenario went well.
According to the above screen shot the do Login should be done successfully and user should be already logged-in
But Actually the login didn’t happen , so this step of our scenario is not a successful one.
The reason that this step is failing is because I disabled the “HTTP cookie Manager” which is in most cases required in the login scenarios.
Let’s try to use the Response Assertion we mentioned earlier in this article and try to validate our scenario but before we do this let’s enable the Cookie manager to choose which text we can use in our validation step.
Now we have a successful login , so I think we can use the “Sign off” text as our asserion , because the sign off link will not be displayed if the user is not logged-in.
I added a response assertion as a child to the do login request , use the Text response and also put “Sign off” as the text to search for in the response.
I will do a trial with the Cookie manager on , then I will re-run the test with the cookie manager off to check that our validation (assertion) is working.
When I execute the test with the Cookie manager disabled , now we have a failed request although we have a 200 response code as shown on the following image.
Text Assertion is not the only assertion we can use but I think it is the mostly used one , and it will help you validate from the script side that you test is doing what should be done , help you have accurate results and have look about how your script and system under test is behaving.
*The JMX used in this article is uploaded here , feel free to use.
Leave a Reply