Find Related products on Amazon

Shop on Amazon

Differential Coverage for Debugging

Published on: 2025-08-12 10:01:24

Differential Coverage for Debugging Posted on Friday, April 25, 2025. I have been debugging some code I did not write and was reminded of this technique. I’m sure it’s a very old debugging technique (like bisection), but it should be more widely known. Suppose you have one test case that’s failing. You can get a sense of what code might be involved by comparing the code coverage of successful tests with the code coverage of the failing test. For example, I’ve inserted a bug into my development copy of math/big : $ go test --- FAIL: TestAddSub (0.00s) int_test.go:2020: addSub(-0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) = -0x0, -0x1fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, want 0x0, -0x1fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe FAIL exit status 1 FAIL math/big 7.528s $ Let’s collect a passing and failing profile: $ go test -coverprofile=c1.prof ... Read full article.