How to Switch From Functional to Load API Testing and Back
Today as a developer you’re expected to deliver quality code fast, and ideally do QA yourself. To be able to provide quality at speed you need to make sure you have tests in place that cover your back. When developing APIs, one important type of test you should run is functional API testing. Functional API testing is about making sure your API fulfills the functional requirements.
These requirements can be defined in different ways. For example:
1. Based on an API documentation such as Swagger
API functions (verb and endpoint combinations) are tested sequentially and individually with various values for their parameters to cover positive, negative and edge cases.
2. Based on business or user scenarios
Tests are created according to the way users use the system. This means you test how the API functions work together, just like a user would experience them. Tests should be constructed according to user scenarios. E.g., a user comes to the website, searches for a product, adds it to the shopping cart, goes to checkout and enters their credit card details to complete a purchase. One way to define such a scenario is by using a tool like JMeter.
Reusing Functional API Tests as Load Tests
Functional API testing is a precondition for running performance tests such as load tests on your API. If your API doesn’t work at all it will definitely not work under load.
That being said it might make sense to reuse your functional API tests as load tests. Tools like JMeter allow you to define assertions to check functional correctness, and run a test at low concurrency and with one iteration to make sure your API works from a functional point of view. Learn more about how to run functional API tests directly through JMeter with HTTP Samplers and Response Assertions, from this blog post. Once your API passes the functional test, simply change the test configuration (concurrency, ramp up time, iterations, duration, etc.) and run it again to test the performance of your API.
You can also transform existing functional tests created with other tools to load tests. For example: if you use SoapUI to create and run your functional tests, then you can transform them to JMX through Taurus and then run them as load tests through JMeter. Read this blog post to learn how to do that.
Another way is to write your functional API tests in Python, and then transform the tests to Locust. Or, you can run the Python tests in Selenium, transform them to Taurus and run then through any open-source load testing tool.
Reusing Load Tests as Functional API Tests
If you are coming from the other direction and you have load tests, you might also be able to reuse them as functional API tests. For example take your existing JMeter load tests and change the test configuration accordingly (concurrency, iterations,...).
A wide range of tools are available today for functional testing, like Postman, SoapUI and Runscope. But also check out API Test, and watch this webinar, Functional API Testing - Auto-Generation, Execution and Reporting to see it in action.
Learn more about how to test your APIs from this blog post: “REST API Testing - How to Do it Right”.
To start your performance and load tests, request a BlazeMeter demo or put your JMX file or URL in the box below, and your test will start in minutes.