Go "no test files" with -tags excluded - Fix in CI
Files behind a //go:build tag are invisible to the compiler unless the tag is requested. Tests in those files silently do not run, so coverage drops and "no test files" appears for the package.
What this error means
CI reports [no test files] for a package that clearly has integration tests, or the integration suite never runs. The tests are gated behind a build tag the test command did not pass.
go
? example.com/app/integration [no test files]Common causes
Build tag not passed to go test
The integration files carry //go:build integration, but go test ran without -tags integration, so they were excluded.
Tag name mismatch
The directive tag and the -tags value differ in spelling or case, so nothing matches and the files stay excluded.
How to fix it
Pass the matching build tag
- Run the integration suite with the same tag the files declare.
shell
go test -tags integration ./...Align the directive and the flag
- Confirm the file header tag exactly matches the -tags value.
Go
//go:build integration
package integrationHow to prevent it
- Document which tags each suite needs and pass them in CI.
- Keep the //go:build tag name and the -tags value identical.
- Add a CI job per tag so gated suites always run.
Related guides
Go -short skipped all tests (empty run) - Fix in CIFix Go testing where -short skipped every test in CI - testing.Short() guarded the whole suite. Drop -short f…
Go "testing: warning: no tests to run" - Fix in CIFix Go "testing: warning: no tests to run" in CI - the -run regexp matched nothing. Fix the pattern or the te…
Go "go generate: no such tool" - Fix in CIFix Go "go generate" failing with "no such tool" in CI - the //go:generate directive named a generator that i…