Skip to content
Latchkey

Go "no test files" / "[no test files]" - Fix in CI

When a package has no _test.go files, go test reports [no test files] and passes it trivially. That is benign unless you expected tests to run there.

What this error means

CI shows ? example.com/app/pkg [no test files] for a package you thought had tests, and a coverage gate passes on zero coverage. It usually means a misnamed file or a missing test build tag.

go
?   	example.com/app/pkg	[no test files]
ok  	example.com/app/other	0.012s

Common causes

Test file misnamed

A test file does not end in _test.go, so Go does not treat it as a test and the package looks empty.

Tests gated behind a build tag

All test files require a tag CI does not set, so none are included.

How to fix it

Fix file naming

  1. Rename test files to end in _test.go so Go compiles them as tests.
Terminal
git mv pkg_tests.go pkg_test.go
go test ./...

Pass the test build tag

  1. Add the tag the test files require so they are included in CI.
.github/workflows/ci.yml
go test -tags integration ./...

How to prevent it

  • Name every test file with the _test.go suffix.
  • Avoid coverage gates that pass on zero measured packages.
  • Set the required test tags in CI.

Frequently asked questions

What causes ""[no test files]""?
A test file does not end in _test.go, so Go does not treat it as a test and the package looks empty.
How do I fix "[no test files]"?
Fix file naming

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card