I am trying to set up a continuos integration environment (using quick build) wherein on every commit to a git branch I want to run our test suite, check code coverage and revert commits if either the test fails or the code coverage is below a certain threshold. In particular I want to ensure that the code I am checking in is 100% tested. Our test suite has been set up using grunt and mocha-hack and we are using grunt-mocha-cov for coverage. But grunt-mocha-cov instruments the whole source code. I want only the git diffs to be instrumented. Is there a way to do this?
Asked
Active
Viewed 821 times
5
-
(full disclosure, I built this) You can use https://codecov.io to upload reports and create Github Status updates. – Steve Peak Feb 10 '15 at 22:25
1 Answers
0
There is a tool named diff-cover, which can check coverage for git diffs. It takes Cobertura XML coverage reports and compares with the output of git diff
. It then reports coverage information for lines in the diff.
I cannot see whether grunt-mocha-cov is able to output Cobertura reports, but you should be able to find some grunt plugin that does.
Note that diff-cover doesn't help you to avoid unneccessary coverage instrumentation for performance reasons.

Dag Høidahl
- 7,873
- 8
- 53
- 66