简体   繁体   中英

How to get code coverage using postman test

We have REST services created in RestEasy and running in wildfly server. We are running Postman test cases to test the Rest URLs.

Is there a way to get a code coverage of the services when we execute postman test suite?

We use SonarQube to analyse the code coverage.

I think no, a similar question was asked here: Generate Sonar code coverage report from Postman tests

The original poster commented further down:

In fact, after a bit of googling, as a work-around we could use remote Jacoco agent hooked in the java application server. We'll try to run jacoco maven goals before and after the tests execution in order to generate jacoco coverage report. See: link I'll update the post if we have some progress.

Also, newman seems to have aticket about it: https://github.com/postmanlabs/newman/issues/408

Though this might help

Karate is the answer to your problem, provided you are willing to switch to another testing framework.

Here is the link to the demo-example which has code-coverage working: https://github.com/intuit/karate/tree/master/karate-demo#code-coverage-using-jacoco . Since Karate is a JVM implementation it is straightforward, and I recommend you keep Karate tests in the same Maven module (or equivalent) for the easiest option. Otherwise it is possible, but just harder - and you will need to fiddle with a Maven profile etc or do some instrumentation synchronization gymnastics.

I guess if you already have a lot of tests in Postman, the advice here may not be practical. But I'm posting this answer for the benefit of others who will come across this question in the future.

If you are lucky, you may be able to quickly port your tests to Karate using the experimental converter built into the UI: https://github.com/intuit/karate/wiki/Karate-UI#postman-import

Perhaps you can contribute to making that feature prod-ready.

There is nothing available that provides code coverage for postman tests.

In the end we chose rest assured and started replacing all postman tests.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM