SupercovCompare
← All comparisons

Go · Comparison

Go test coverage: go test -cover, gomcdc and Supercov

MC/DC and branch coverage for Go: go test -cover measures statements, gomcdc adds MC/DC on Go 1.26, and Supercov adds MC/DC, per-test and assertion coverage on 1.22+.

go test -cover vs gomcdc vs Supercov

Start with go test -cover. It is built into the Go toolchain, needs no dependency, and tells you which statements ran. For MC/DC there are two options: gomcdc, a Go MC/DC tool for Go 1.26 and newer, and Supercov, which runs your own go test command on Go 1.22 and newer and adds coverage per test and which statements your assertions check.

Coverage features
Featurego test -cover1.27.1Supercov2.0.0
Code quality scoringNot built inSupported
Security reviewNot built inSupported
Line coverageSupportedSupported
Branch coverageNot built inSupported
MC/DCNot built inSupported
Per-test coverageNot built inSupported
Assertion coverageNot built inSupported
ReportsSupportedSupported

✓ Supported · × Not built in. Standard coverage workflows in the versions shown; custom plugins are outside this table.

Supercov requires Go 1.22 or newer and runs your own `go test` command against an instrumented copy of the module.

The Go toolchain counts statements per run. A test that calls t.Parallel() shares one counter array with the tests beside it, so Supercov counts that coverage run-wide rather than naming a test for it.

Per-test coverage means individual tests, not just test files. Supercov needs a supported runner. Assertion coverage is Jev’s judgment, test by test, of whether changing each executed statement would make the test fail; it is not a mutation score or a correctness guarantee. Security review comes from Supercov’s Jev checks; reports means a browsable HTML report from the tool itself.

go test -cover: statements, one profile per run

go test -cover ./...
go test -coverprofile=cover.out ./...
go tool cover -html=cover.out

The unit is the statement. In the default mode the question is, in the Go documentation’s words, “does this statement run?”; -covermode=count counts how many times, and -race switches the default to atomic. -coverpkg widens coverage beyond the package under test.

The profile covers the whole run. It does not say which test ran a statement, and it has no notion of a branch outcome: both sides of an if are just the statements inside them. The Go blog’s coverage article explains the design.

gomcdc: MC/DC for Go 1.26 and newer

gomcdc runs your package tests itself and writes one report with statement, function, decision, condition, switch-clause and MC/DC results, in both the unique-cause and the masking form. It needs Go 1.26 or newer, a module, and Linux or macOS, and it writes text, JSON or HTML:

go install github.com/shrydev2020/gomcdc/v2@v2.0.0
gomcdc test ./...

It is MIT-licensed and was last released in July 2026. Its documentation does not describe coverage per test or assertion coverage. Choose it when you need both MC/DC forms in one report and your project is on Go 1.26.

What MC/DC adds to a Go test

func CanAccess(signedIn, expired bool) bool {
	if signedIn && !expired {
		return true
	}
	return false
}

func TestAccess(t *testing.T) {
	if !CanAccess(true, false) {
		t.Fatal("active session denied")
	}
	if CanAccess(false, false) {
		t.Fatal("signed-out visitor allowed")
	}
}

Every statement runs, so go test -cover reports 100%. Yet no test has a signed-in user with an expired session, so nothing shows that expiry can deny access on its own. Add CanAccess(true, true) to cover it. This is an illustrative example, not a published cross-tool Go measurement.

Where Supercov fits

With Go 1.22 or newer, run your own test command through Supercov:

go run github.com/supercorp-ai/supercov/cmd/supercov@latest -- go test ./...
go run github.com/supercorp-ai/supercov/cmd/supercov@latest runs latest gaps

It instruments a copy of the module, so your source tree is unchanged, and it reports the missing condition above by name. The Go guide has the setup and a runnable example; runner support covers parallel tests and the other limits.

Keep go test -cover when a statement percentage answers your question. Use gomcdc for a single MC/DC report on Go 1.26. Use Supercov on Go 1.22 and newer, or when you, or your coding agent, need to know which test ran a line, which checks are missing, and which test would close the gap. Neither score proves the program correct.

Feature sources