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.
? example.com/app/pkg [no test files]
ok example.com/app/other 0.012sCommon 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
- Rename test files to end in _test.go so Go compiles them as tests.
git mv pkg_tests.go pkg_test.go
go test ./...Pass the test build tag
- Add the tag the test files require so they are included in CI.
go test -tags integration ./...How to prevent it
- Name every test file with the
_test.gosuffix. - Avoid coverage gates that pass on zero measured packages.
- Set the required test tags in CI.