I am adding unit tests to some existing code which initially was not tested at all.
I have set up my CI system to fail builds where the code coverage percentage is reduced compared to previous build - mainly to set a path of continuing improvement.
I then encountered an unexpected and annoying (although mathematically correct) situation that can be reduced to the following:
Before refactor:
Method 1: 100 lines of code, 10 covered --> 10% coverage
Method 2: 20 lines of code, 15 covered --> 75% coverageTotal: 25 / 120 --> ~20% coverage
After refactor:
Method 1: 100 lines of code, 10 covered --> 10% coverage (untouched)
Method 2: 5 lines of code, 5 covered --> 100% coverageTotal: 15 / 105 --> ~14% coverage
So even though IMO the situation was improved, my CI system obviously does not agree.
Admittedly, this is a very esoteric problem, and would probably disappear when the bulk of the code will be covered better, but I would appreciate insights and ideas (or tools/configurations) that might allow me to keep enforcing an "improvement" path for coverage with my CI system.
The environment is Java, Jenkins, JaCoCo.