Is there any way I can generate an "empty" or "all red" coverage report, even when no code in a project has been called?
I'll share my use case so that this hopefully makes more sense. I'm using maven and the jacoco-maven-plugin.
Internally, the team I work for has a maven plugin that calculates how much coverage a given GitHub pull request has. We don't want to check the code coverage of the project as a whole as some of them are legacy projects with close to 0% and we just want to enforce the adding of tests for new changes. Our method is as follows: we check the git diff vs master, see which lines of which files in this diff appear in some coverage report and then figure out what percentage of those has code coverage.
Here is the current issue we are having: there is one project in a particularly bad state with literally zero tests. Since there are no tests, no jacoco.exec file is output at the end of the maven test lifecycle, so no report is generated. This obviously makes sense since a module could be config or some other non-java code that jacoco is not interested in. However, in our case we are left with no way of determining which lines are executable in the project and therefore default to thinking it is not coverable meaning that until at least one test is added, all PRs will pass our checks.
Is there any way to force the creation of a jacoco.exec file that just says there were no lines covered at all? Is this option exposed in the jacoco maven plugin?
Thanks,
K
Is this option exposed in the jacoco maven plugin?
Is there any way to force the creation of a jacoco.exec file that just says there were no lines covered at all?
The fake test solution was the first thing we tried, and found that ti didn't work unless we explicitly called code in the module within the test. A dummy test was not enough to force a report to be generated.