The improvement to code quality that drops the coverage metric 40%!

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

    Reply here

    Your email address will not be published. Required fields are marked *

    Reply on your own site

    Reply elsewhere

    You can reply to this post on Mastodon (@blog@danq.me).

    Reply by email

    I'd love to hear what you think. Send an email to b29374@danq.me; be sure to let me know if you're happy for your comment to appear on the Web!