In the article Performance Testing Framework, it described how performance testing can be done early by reusing the test automation artifacts, thereby preventing duplication of effort and saving time and money. This is an ideal way to create performance scripts for browser-based applications. But what about API testing?
Before continuing it is worth explaining what API is and what API testing involves. API stands for Application Programming Interface, allowing applications to communicate with each other.
An API client messenger sends a request to a provider you’re a requesting it from, which in turn delivers a response back to the messenger. API testing will involve the validation of the request and response from the messenger and provider respectively, and in turn API performance testing is doing this at scale.
Now the question arises: if there is a need to do API performance testing, would you also need to create automation tests in Java or Visual Studio for example? This may seem like an odd question, but it really isn’t. In browser testing the reason is obvious – performance testing tools don’t test the browser, but it captures the traffic from a browser and replays it. It would be difficult to come up with the combination of tests to properly do this using a performance tool. For API testing this is less of an issue, in fact if it was developed using API libraries in an automation framework setting (using Java or Visual Studio) or a performance tool framework setting then very little is different.
Popular performance testing tools such as, JMeter (Apache), NeoLoad (Neotys) and LoadRunner (Micro Focus) can do API testing right out of the box and have powerful tools to make setting up and running a test straightforward. So, creating an API test using one of these performance tools, it can be used for both functional and performance tests so there is no need to duplicate.
What do performance testing tools have in their arsenal to be suited for both API functional and performance testing? The following are some of them –
- Parameterization of data in the requests, therefore, there is no need for hard-coded data.
- Test data can be stored in CSV files so is easy to setup and used in the parameterization of requests.
- Methods to extract data from the responses is built-in into the tool which can then be used in subsequent requests.
- Assertions can be set up to validate the responses.
- Test reports can be produced easily.
So, API testing can be set up in a performance test tool and used for both functional and performance tests saving time and money.