Skip to content
Latchkey

go vet "wrong signature for TestX, must be func TestX(t *testing.T)" in CI

The tests analyzer checks that functions named TestXxx take exactly (t *testing.T). A wrong signature would otherwise be silently skipped by the test runner, so vet reports it.

What this error means

go vet or go test reports "wrong signature for TestFoo, must be: func TestFoo(t *testing.T)".

go vet
./svc_test.go:9:1: wrong signature for TestFetch, must be: func TestFetch(t *testing.T)

Common causes

The test takes the wrong parameter type

A function named TestXxx declares a different parameter (or none), so the testing package would not call it as a test.

A helper accidentally named with a Test prefix

A non-test helper was named TestXxx, colliding with the convention the runner relies on.

How to fix it

Use the standard test signature

  1. Change the parameter to t *testing.T (or b *testing.B for BenchmarkXxx).
  2. Rename the function if it is not actually a test.
  3. Re-run go vet ./... and go test ./....
svc_test.go
func TestFetch(t *testing.T) {
	// ...
}

Rename non-test helpers

Give helper functions a name that does not start with Test, Benchmark, Example, or Fuzz.

How to prevent it

  • Run go vet ./... in CI so mis-signed tests are caught.
  • Reserve the Test/Benchmark/Example/Fuzz prefixes for real test functions.
  • Use table-driven tests with the standard signature.

Related guides

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