Skip to content
Latchkey

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

  1. Match the regexp to the actual test name (anchors and case matter).
shell
go test -run '^TestCheckout$' ./...

List tests to verify names

  1. 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

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →