تخطَّ إلى المحتوى

Test Method Naming (ARCH5008)

هذا المحتوى غير متوفر بلغتك بعد.

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.

func testUserLogin(t *testing.T) { // lowercase 't', not discovered
if !login("alice") {
t.Fatal("login failed")
}
}
func TestUserLogin(t *testing.T) {
if !login("alice") {
t.Fatal("login failed")
}
}

Name test functions with the Test prefix and an uppercase continuation.