Skip to content
Latchkey

Go "no test files" / "no tests to run" in CI - Fix Empty Test Runs

Go reports [no test files] for packages it found no _test.go files in, and no tests to run when a -run filter matched nothing. Often harmless, but it can hide a suite that silently stopped being discovered.

What this error means

go test ./... prints ok <pkg> [no test files] for packages you expected to test, or testing: warning: no tests to run with a PASS. The run is green but exercised nothing in those packages.

go test output
ok  	github.com/yourorg/app/handler	(cached)
?   	github.com/yourorg/app/store	[no test files]

# or with a -run filter:
testing: warning: no tests to run
PASS

Common causes

Test files not named *_test.go

Go only treats files ending in _test.go as tests. A file named store_tests.go or test_store.go is compiled as normal source and contributes no tests.

Test functions don’t match the convention

Test functions must be func TestXxx(t *testing.T) with an exported name. A lowercase or wrong-signature function is ignored.

A -run pattern matched nothing

A -run regex that does not match any test name yields no tests to run - a typo or an over-narrow filter.

How to fix it

List what go test discovers

Enumerate the test names so you can see which packages actually contribute tests.

Terminal
go test -list '.*' ./...

Fix naming conventions

  1. Rename test files to end in _test.go.
  2. Make test functions func TestXxx(t *testing.T) with a capitalized name after Test.
  3. Check any -run regex actually matches your test names.

Fail CI when whole packages have no tests, if intended

If a package must have tests, assert coverage so an empty package is caught rather than passing silently.

.github/workflows/ci.yml
go test -cover ./... | tee cover.txt
grep -q 'no test files' cover.txt && echo 'missing tests' && exit 1 || true

How to prevent it

  • Name test files *_test.go and functions TestXxx.
  • Review -run filters so they are not over-narrow.
  • Track coverage so a package silently losing its tests is visible.

Related guides

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