I’m sure most of us aspire to use a Test-Driven Development approach to our coding – it forces clarity on requirement definition and can be invaluable in supporting alignment between team members/different services for an app. This would typically take the form of unit testing but, to test the full functionality of an API endpoint it requires a slightly different set of tools.
As my capstone team continues work on our own API we want to make sure we hand off a complete set of tools to our industry partner at the end of the project – including an API test suite. So – which tool to use? Through our own professional and academic experiences with these tools, we are currently deciding between two tools – Postman and Swagger.
Postman offers a friendly UI that can be completely separate from the app repository/deployment. Postman allows you to:
- import both an environment and a test suite
- define multiple tests for the same endpoint
- set local or environmental variables – both before and after calls
- run an entire suite of tests with a single click
Alternatively, Swagger is more closely integrated with the code itself. Swagger allows you to:
- define parameters, descriptions, and defaults using decorators directly within the code
- perform manual testing in a user-friendly GUI where both the response and request are clearly laid out, side by side
Both tools offer automated testing tools – helpful for integration or reliability testing – and have similar price points. Assuming that running the app (or accessing its deployment) is trivial – Swagger offers a very friendly UI and makes it easy to incorporate Swagger documentation into coding comments and code review. It does require a “home” for the GUI but can be nicely incorporated into a team’s wiki. Postman feels like a more compartmentalized option – assuming the users have some familiarity with Postman, importing the environment and test collection is easy.
For my team’s use case – where we will not be maintaining the project in the long-term – Postman seems like the logical choice since we don’t know how our industry partner will ultimately deploy the app and Postman’s environment configurations are easily changed.