Working with an old codebase today, I moved a method from one file to another. CI was happy.
Then I realised the method didn’t have any automated tests, so I wrote one. It turns out its entire (new) file didn’t have any, so my change would improve test coverage. Nice.
But it didn’t. CI complained that test coverage had dropped. Wait, what? All I did was move some code and add a unit test.
Then I realised that the coverage analysis tool was only counting files that actually contained any tested code. By adding a test to part of a previously-untested file, that file became part of the scored codebase. Uh-oh.
Looked deeper. Turns out the code coverage tool was also counting the test files themselves as being part of the code-under-test.
Fixed all of the above. Code coverage score dropped by about 40%. 😱
Now I’ve got more work to do.
Happy Friday. Check what your coverage tool is inspecting, folks.
0 comments