Search by labels

Tuesday, January 14, 2020

How to setup a performance test suite with Apache JMeter

The Apache JMeter™ application is open source software, a 100% pure Java application designed to load test functional behavior and measure performance. It was originally designed for testing Web Applications but has since expanded to other test functions

To run JMeter you need Java Development Kit 8 or higher installed.
In this tutorial we will be testing https://pokeapi.co/, a RESTful API that returns Pokémon data.

1. Start by adding a Thread Group, through this component you will be able to control the number of threads, how they start and other aspects.



2. Implement a basic GET request for returning data about a certain Pokémon and add a Listener component to visualize the results.



3. Add Assertions on the response. 



As shown in the video, you can check the basic elements like response code and message or go in-depth and extract other values from the payload with regular expressions (useful tool for working with regex here).

At this point the test is strongly hardcoded and hard to maintain over time. For example, if there were 100 tests in this suite and the server or the endpoint would change, you would have to manually update each one. So in the next step let's parametrize the test and keep the variables in a central component.

4. Centralize the variables in Config elements.



5.  Extend the testing for multiple Pokémons.



6. Add a Summary Report and start testing on multiple threads.



A number of threads of 100 with a ramp-up period of 10 seconds means that each 100 milliseconds a new thread will be opened.

You can use the Jenkins Performance plugin to execute such test suites remotely and periodically.

No comments:

Post a Comment