| April 12, 2022 | in
Postman is a tool we use to test our APIs while building them. Its UI helps make this stage in development quick and easy. But a lot of the work we do in Postman is often single-use. We write the tests, but why can’t we keep them?
Actually, we can keep them. Follow along as I step through an example.
Let’s assume we have a couple of Postman requests: one to create organizations and one to create contacts.
Creating tests for these doesn’t require much effort. We just need to add some code in the test tab.
The test code is pretty much standard BDD assertions. You can write whatever you want to verify that your code has run successfully. In the example above, I am verifying that the status returned is “OK”.
Next, we can build out a collection of tests so we can run all of them at once. Using collections allows us to run more of an integration test against our entire system. If they are hitting actual endpoints, things such as data mapping will be tested. If they are run against environments, environment-level configurations will be tested.
Using Postman to build out API tests allows you to put the Postman investment to work. In a later blog post, I’ll cover using Newman to automate these tests as part of a release process.