postmanlabs / newman

Newman is a command-line collection runner for Postman
https://www.postman.com
Apache License 2.0
6.88k stars 1.16k forks source link

Is there any way for newman tests to contribute to code coverage? #408

Closed reggi closed 8 years ago

reggi commented 8 years ago

Not even sure what this really entails. But the idea is I'd like to pipe in newman tests to account for my code coverage. Is this something that is possible?

czardoz commented 8 years ago

Interesting. This is totally dependent on your technology stack though. If it allows measurement of code coverage when running certain external commands, maybe it's possible.

E.g: If I were using Python's unittest module, I could probably write a test-case that calls Newman, and generate code coverage reports using something like coveralls.

I don't think there's any chance of having such a functionality built into Newman however, because of the number of different technologies people use to build their APIs.

gkgeorgiev commented 8 years ago

https://stackoverflow.com/questions/39835992/generate-sonar-code-coverage-report-from-postman-tests

tkssharma commented 6 years ago
describe('newman', () => {
  // done on the next line is a function that marks the current test as asynchronous
  it('should run collection correctly', function (done) {
    this.timeout(100000); // 10 seconds
    newman.run({
      collection: (require('../API-Automation.postman_collection.json')),
      environment: (require('../dev_environment.postman_environment.json')),
      reporters: 'cli'
    }, (err, summary) => {
      console.log(summary.run.failures.length);
      if (err) { return done(err); }
      done();
    });
  });
});

Plug it with nyc/istanbul so we can capture coverage on same server instance !! this will help a lot i am still trying to figure this out how can be done with node APIs