Code coverage with Postman /Newman

I have test cases written in postman for testing APIs
I use Newman command line integration for running my collection.

I just got a new requirement for code coverage now.
I want to to know is there any way or any integration by which I can know my code coverage without rewriting whole tests??

PS: I have my code in nodeJs.

I think you need to question what should the Postman tests cover. Just because it is a requirement, does not necessarily mean it makes sense and it is a good idea.

Postman does not interact with your code, it interacts with the API that the application exposes. As Postman does not have access to the code directly, it cannot report back which code was executed.

Code coverage is usually a requirement that applies to unit testing or similar tests that are executed directly on the code.

Postman is an API testing tool, it implicitly tests how the entire system made of components works together.

So unit testing / API testing (or integration testing) are two different things with different purposes.

I know Postman is tool for API testing and doesn’t interact with code.
That is why I have this question that “Is there any tool/framework where I can just export my Postman collections and then integrate that with my source code”?


@vdespa I have a question. So the Postman Test that is written with either jest, mocha or chia. How do you create a type of coverage that will send back the results of what you tested. Just by grabing that information over the test you covered. I am trying to do something similar but I want to create a code coverage that not looking at the direct code but just the coverage of what my test is stating I am testing? Is that possible?

A Postman test is written using tests which contain assertions. The most of the assertions are using the ChaiJS library.

At this level, we can only discuss of coverage in terms of (for example) which endpoints, methods and status codes are covered. For this, you first need to have a way of knowing this in advance and a way to track which aspects were tested.

While is it possible to use the new API tab and to provide a OpenAPI schema, it is not possible to track the coverage.


@vdespa thank you for this response.