Test Method Naming (ARCH5008)
Esta página aún no está disponible en tu idioma.
Key go.naming.test-name-convention · Severity info · Category naming
Test functions should follow the framework’s discovery convention; in Go a test function must start with Test and the part after it must begin with an uppercase letter. Otherwise go test will not pick them up.
Incorrect
Section titled “Incorrect”func testUserLogin(t *testing.T) { // lowercase 't', not discovered if !login("alice") { t.Fatal("login failed") }}Correct
Section titled “Correct”func TestUserLogin(t *testing.T) { if !login("alice") { t.Fatal("login failed") }}Name test functions with the Test prefix and an uppercase continuation.