Skip to main content
blog.philz.dev

Coverage

if you liked it, then you should have put a test on it

Sometimes, the question arises: which tests trigger this code here? Maybe I've found a block of code that doesn't look like it can't be hit, but it's hard to prove. Or I want to answer the age-old question of which subset of quick tests might be useful to run if the full test suite is kinda slow.

So, run each test with coverage by itself. Then, instead of merging all the coverage data, find which tests cover the line in question. Oddly enough, though some of the Java tools (e.g., Clover) support per-test coverage, the tools here in general are somewhat lacking. genhtml, part of the lcov suite, supports a TN: ("test name") marker, but only displays the per test data on a per-file level:

lcov sample output

This is the kind of thing where in 2025, you can ask a coding agent to vibe-code or vibe-modify a generator, and it'll work fine.

I have not found the equivalent of Profilerpedia for coverage file formats, but the lowest common denominator seems to be LCOV. The file format is described at geninfo(1). Most language ecosystems can either produce LCOV output directly or have pre-existing conversion tools.