![]() Besides that you can create your own reporter to format the report in any format you want.Ĭool, we have defined our API test suite with Postman and we are able to run it from command line and obtain a nice report of the results so far with Newman. To achieve this, Newman provides a set of reporters to support different output formats like JSON, XUNIT or HTML. The report can be formatted in different ways. $ newman run our.postman_collection.json -e our.postman_environment.jsonĪnd we will see a report of the collection run, similar to others testing frameworks. Once we have both files, we are able to run the collection with: Since we have some variables playing around in some of our request, we have to export the suitable environment too. In order to run a collection with Newman, we first have to export it from Postman. Newman is a command line Collection Runner for Postman that allows you to run and test a Postman Collection directly from the command line and integrate it easily in CI servers, that makes it a great tool for our purpose: Automate our API test with Jenkins. But what about a command line tool to do the same? Newman does it. What a time to be alive!ĭo you remember the Collection Runner I mentioned previously? It could run every request in our collection with a simple click. ![]() ![]() Besides that, every request has several tests to check if it is working properly. Sweet! Once we have written a test suite to cover our API, we use the Collection Runner, a built-in tool provided by Postman to run every request of a collection and output a report of tests results.īonus: Sometimes, we want to run our requests in a certain order and guess what? Postman allows us to do it! Check it at building workflows issueĪt this point, we have build up a Postman collection with a bunch of request that could target our API in all our environments. They are written in JS and have a cool set of assertions to check things like the response code, response body o response headers. One of the greatest features of Postman is that allows you to code tests that runs every time a request run. Think about how easy would be to change or add a new environment!Įxtracting base path as environment variable to target different environments This way I can define a single request but target it to my three different environments easily. Giving a real example, I would tell you I work on three different environments: my local environment, a staging environment and a production environment, so I create three different environments with variables which represents the changing data between the environments (like the base path for the API requests). Postman allows us to create different environments to run our requests. Then, inside the collection, I create a folder for every entity on the project, trying to cover every endpoint in the API. Personally I create a collection for every project I want to test. Postman makes easy to organize our different request into collections. It has a great documentation and an increasingly community of developers which use it, so it is easy to find posts explaining cool tips and tricks. Postman is a great tool that helps developers in every stage of our API lifecycle. Having an API Test Stage in our CI pipeline brings us confidence in the quality of the product and alerts us if something had broken. ![]() Nowadays CI pipelines are a must on our development dayjob, helping us to shorten delivery cycles and to bring higher quality software.Īs a backend developer, APIs have became a cornestone on most of my applications, so testing them became a must.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |