Regression test with JMeter
JMeter was originally created as a load and performance test tool, but thanks to its constant development it offers other possibilities, one of which is automating a simple (but useful) regression test. Because of its very handy features like the assertions, extractors and listeners, automating a regression test in JMeter is fairly easy to set up, run and view the results.
(At the time of writing, the latest version of JMeter is 2.4, so bear in mind that future versions could differ a bit.)
Usually a test starts with a home page, so we’ll start from there. First we have to add a thread group to our test plan (e.g. right-click on Test Plan, Add > Threads > Thread Group) and add a sampler to send a HTTP request (right-click on the previously added
thread group, Add > Sampler > HTTP Request). To configure the request with the intended URL, fill in the “Server Name or IP” field (in our example that’s www.fiveminutes.eu). Also, we need to configure the Thread Group (which represents a user): just leave all values to 1.
To see response data we’ll need a “View Results Tree” listener. Right-click on the Test Plan, Add > Listener > View Results Tree. Note that test elements can be rearranged by dragging them up and down the tree. You can run the script now to see what happens (Run > Start). Select the “View Results Tree” and “Response data” tab to see the HTML of the targeted web page.
Next thing to do is to add some response assertions. There is a nice general purpose assertion module that supports RegEx
(right-click the HTTP Request > Add > Assertions > Response Assertion). It can be used to check whatever needs to be checked – from response code to specific tags and text. The trick is to find out which elements on the page are best to serve as a check that the page is correct.
To make our test dynamic, we can use RegEx extractor to extract a link for the next step.
Now we can add the next request (the extracted Blog page) and again add some assertions and extractors.
And finally add a request for the blog detail page, same as we did for the previous request.
That’s it, a small regression test to give a basic idea of the concept. Further steps are just a matter of deciding what do we want to validate and selecting the appropriate assertion. Stay tuned for more!