![]() And, as you’ll see later in this article, having your tests separated in their own collection opens up some powerful automation possibilities. Yes, that means that you have to manage two different collections, but in my experience, the contents of these collections end up being so vastly different that there’s almost no overlap or duplication between them. Documentation (especially public docs) may be written by your marketing team or technical writers, whereas tests are written by the developers who built the API or the testers who are responsible for validating the API.įor all of these reasons, I highly recommend that you keep your API tests in a separate collection from your API documentation. A solid test suite will include many edge cases, intentional bad inputs (to test error handling), and possibly reveal sensitive information, all of which would be irrelevant or confusing for your API’s consumers.Īnd finally, the authors are possibly different. Whereas API documentation is for the consumers of an API, tests are for the authors of an API. Your API tests, on the other hand, serve an entirely separate purpose.įirst of all, the audience is different. For both of those use cases, it makes sense for your collection to contain detailed explanations for each of your API endpoints, walkthroughs of common API workflows, authentication requirements, lists of possible error responses, etc. Many people use Postman Collections to document their APIs, either as a collection of example requests that can be easily shared among team members, or as public API documentation for customers. TIP #2: don’t mix tests and documentation Testing simple things, like HTTP status codes, response times, and headers can each be done in a single line of code, like this:īut you can also write more advanced JavaScript logic to validate responses, check custom business rules, persist data to variables, or even dynamically control Postman’s workflow. Writing tests in Postman is easy and uses JavaScript syntax. As your codebase grows and changes over time, tests will save you time and frustration by spotting breaking changes. Without good tests, it’s impossible to have full confidence in your API’s behavior, consistency, or backward compatibility. The first step to API testing is to actually do it. Related: Use the API Testing Templates TIP #1: write tests Over the years, I’ve picked up 10 tips and tricks for simplifying and automating the task of API testing. As an engineer at Postman, I talk to a lot of people who use Postman to test their APIs.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |