unit-testingcode-coveragejacocojacoco-maven-plugin

Is there a way to get unit coverage percentage (eg from jacoco) on only new code?


My hypothethical scenario is this:

Now the intersection of my git diff and the jacoco information is that 7 of the 10 lines of code changed are covered. ie - I have 70% coverage on new code.

But I had to work that out manually.

I'd like an automated way to work out the percentage how many new lines of code are covered.

My question is: Is there a way to get unit coverage percentage (eg from jacoco) on only new code?

(Note I know sonarqube can do this if you run the scanner with analysis.mode=publish and get interrogate the task result with the JSON API - I'm looking for something lightweight that a developer can run locally.)


Solution

  • Have a read of this: https://juliangamble.com/blog/2017/09/01/commit-level-coverage-reporting/

    Then use this project: https://github.com/juliangamble/commit-level-coverage-report