Coverage for end-to-end tests of Go programs

Getting coverage of Go unit tests (the ones in _test.go files) is easy, but there's no documented way to get coverage of tests run externally, against a running "main" binary, like integration tests.

I wrote about a hack I used to solve this on the CloudFlare Blog. It amounts to making a special test case that runs main(), putting it behind a build flag and compiling with go test -c.

Go coverage with external tests | CloudFlare Blog (archive)