Danny Briskin, QA Consultants Senior Automation Engineer
The issue
API development and API testing are well-known things in the modern world of computer technologies. There are a lot of tools, applications, methodologies and best approaches for API testing, from well-known Postman and SOAPUI to a bunch of smaller projects and plugins in development environments. But sometimes, QA engineers are faced with certain difficulties when they need to test an API. Contemporary Agile approach means that API is under constant development during testing phases. And the last thing developers pay attention to - is documentation. Sad but true, there are a lot of projects without any useful documentation at all. Many of them are lack of up-to-date documentation. This raises the question: how to test it if you don’t know where to start?
In best practices we trust
When we deal with SOAP-WSDL API there should be a “.wsdl” file where tester can find a lot of useful information related to available endpoints and parameters. In case of REST API, the only thing we can trust is REST naming convention (Google has the same), the only issue there: we don’t know where to start. Well, if there is a …/customers endpoint, highly likely there will be customer that supports customer/{n}. But not for sure. And, of course, using HATEOAS/HAL approach can greatly increase our knowledge of API (see this article for more information)
Documentation makes us happy
Sure thing, it is not easy for a developer of complex API to maintain documentation full and up to date. Especially manually. Good thing, there are a lot of libraries that can ease a burden. Moreover, it can create not only documentation but an UI for users to test it in a real environment. Let me introduce two projects that can transform your regular API to a perfectly documented project:
- Swagger. Swagger-UI is a tool for visualization and run REST requests. There are implementations of Swagger for different programming languages, including Java and Python. With a bit of configuration in your software, you will be able to see endpoints
Possible errors and their descriptions
and run your own requests
- HAL Explorer. This project can be easily integrated into your project that uses HAL Hypermedia. In case of Spring Data Rest you don’t even need to do anything to configure it. It works out the box.
It will discover all available endpoints
and you can run any request with parameters
even creation of request body is interactive
Summary
Automatic documentation can greatly increase the speed of testing an API because of:
- Developer doesn’t need to spend a lot of time to update current documentation
- QA engineer gets to know with API faster
- Exploration of API can be done easily and much faster that leads to earlier defects detection