I’m looking for a way to prevent the overal code coverage to be lower after a merge.
Issue:
We have a setting that our overal code coverage should be at least 80%. Some projects however do not yet meet this expectation and our below this percentage.
New code should also be at least 80% covered.
We have the issue however that some developers sometimes accidentally push a focused test on their branch. All other tests are than skipped. With fdescribe/ fit for example.
The PR does not fail on this, because the new code may be perfectly tested. But the coverage after merge is than drastically decreased .
Solution?
I would really like some option in the quality gate to prevent the code coverage from being lower after merge.
Or is there some other way to prevent this from happening?
Thank you for the feedback! I have a few clarification questions:
Your Quality Gate on your PR does not fail since the new code is covered, but after merging this to your main branch it fails because the coverage on the main branch is suddenly reduced. And it is reduced because some tests were skipped, and not because the actual coverage went down, right?
The idea is to notice this before the PR will be merged?
Yes this is true. Except that the main branch was already failing. Because that branch does not yet meet our standards. This is why we didn’t immediately notice that the coverage went down on the main branch after the merge.
Exactly. We never want the code coverage of the main branch to be lower after a merge. So it would be nice if we can prevent a merge if that merge would lower our overall code coverage.
Thank you for your insight, we really appreciate the time you took to share it.
There is currently no short-term plan to work on changes here but we’ve added this feedback internally and continue to monitor if this is a wider problem.