Go API testing patterns -- httptest setup, table-driven tests with subtests, test helpers, middleware testing, dependency injection with interfaces, database isolation, parallel tests, testify assertions, golden files
98
98%
Does it follow best practices?
Impact
99%
1.06xAverage score across 5 eval scenarios
Passed
No known issues
{
"context": "Tests whether the agent writes table-driven validation tests for a Go API using the standard Go idiom: a slice of structs with named test cases, iterated with t.Run subtests, covering multiple invalid inputs and at least one valid case.",
"type": "weighted_checklist",
"checklist": [
{
"name": "Test table struct slice",
"description": "Tests define a slice of anonymous structs (tests := []struct{...}{...}) with at least name, body/input, and expected status code fields",
"max_score": 12
},
{
"name": "t.Run subtests",
"description": "Each test case is executed inside t.Run(tt.name, func(t *testing.T) { ... }) for named, filterable subtests",
"max_score": 12
},
{
"name": "Missing name validation",
"description": "There is a test case for a missing/empty name field expecting a 400 response",
"max_score": 8
},
{
"name": "Invalid price validation",
"description": "There is a test case for a zero or negative price expecting a 400 response",
"max_score": 8
},
{
"name": "Invalid category validation",
"description": "There is a test case for an invalid category value expecting a 400 response",
"max_score": 8
},
{
"name": "Missing category validation",
"description": "There is a test case for a missing category field expecting a 400 response",
"max_score": 6
},
{
"name": "Empty body validation",
"description": "There is a test case for an empty JSON body expecting a 400 response",
"max_score": 6
},
{
"name": "Valid case included",
"description": "The test table includes at least one valid input case that expects a 201 response",
"max_score": 10
},
{
"name": "Error body asserted",
"description": "Tests assert the error response body content (checking for error.message or similar), not just the HTTP status code",
"max_score": 10
},
{
"name": "httptest used",
"description": "Tests use httptest.NewRequest and httptest.NewRecorder, not real HTTP calls",
"max_score": 8
},
{
"name": "State reset between tests",
"description": "Tests call resetState() or equivalent before each test to ensure clean state",
"max_score": 6
},
{
"name": "Test helper with t.Helper",
"description": "A makeRequest or similar helper function exists and calls t.Helper()",
"max_score": 6
}
]
}