Go "testing: warning: no tests to run" - Fix in CI
go test -run filters tests by a regexp over their names. A pattern that matches nothing produces an empty run that passes vacuously, hiding the fact that no test executed.
What this error means
CI shows testing: warning: no tests to run and a green PASS, but no assertions ran. The -run regexp did not match any test name.
go
testing: warning: no tests to run
PASS
ok example.com/app 0.012s [no tests to run]Common causes
-run pattern does not match
The regexp passed to -run does not match any TestXxx name, so the run is empty.
Test renamed, filter not updated
A test was renamed but the -run value in CI still targets the old name.
How to fix it
Correct the -run regexp
- Match the regexp to the actual test name (anchors and case matter).
shell
go test -run '^TestCheckout$' ./...List tests to verify names
- Print the test names so the filter targets a real one.
shell
go test -list '.*' ./...How to prevent it
- Verify -run patterns against actual test names.
- Treat "no tests to run" as a failure in CI, not a pass.
- Avoid hardcoding -run filters that drift when tests are renamed.
Related guides
Go "no test files" with -tags excluded - Fix in CIFix Go test seeing "no test files" because integration files are gated behind a build tag in CI - pass the ma…
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 "cannot use -coverprofile with multiple packages" - Fix in CIFix Go "cannot use -coverprofile flag with multiple packages" in CI on older Go - upgrade Go or use -coverpkg…