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 comprehensive CRUD tests for a Go user API using httptest, with test helpers calling t.Helper(), table-driven tests with t.Run, database isolation using :memory: SQLite, and assertions on both status codes and response body shape.",
"type": "weighted_checklist",
"checklist": [
{
"name": "httptest used",
"description": "Tests use httptest.NewRecorder and httptest.NewRequest (or httptest.NewServer) rather than real HTTP calls to localhost",
"max_score": 10
},
{
"name": "memory SQLite",
"description": "Test setup uses sql.Open(\"sqlite3\", \":memory:\") for database isolation, not a file-based database",
"max_score": 10
},
{
"name": "makeRequest helper with t.Helper",
"description": "There is a makeRequest (or similar) helper function that calls t.Helper() and handles request creation, sending, and recording",
"max_score": 10
},
{
"name": "createTestUser helper",
"description": "There is a helper function that creates a test user via the API and returns the response data, reducing duplication across tests",
"max_score": 8
},
{
"name": "table-driven test with t.Run",
"description": "At least one test uses a slice of struct test cases iterated with t.Run(tt.name, ...) for subtests",
"max_score": 10
},
{
"name": "GET list test",
"description": "There is a test that calls GET /api/users and verifies it returns a list",
"max_score": 5
},
{
"name": "POST create test",
"description": "There is a test that calls POST /api/users with valid data and expects 201",
"max_score": 5
},
{
"name": "GET by ID test",
"description": "There is a test that fetches a specific user by ID and verifies the returned data",
"max_score": 5
},
{
"name": "create-then-fetch persistence",
"description": "At least one test creates a user via POST then fetches it via GET to verify the data persisted correctly",
"max_score": 10
},
{
"name": "404 for nonexistent user",
"description": "There is a test that requests a nonexistent user ID and expects a 404 response",
"max_score": 8
},
{
"name": "400 for invalid input",
"description": "There is a test that sends invalid/incomplete data to POST /api/users and expects a 400 response",
"max_score": 8
},
{
"name": "response body shape asserted",
"description": "Tests assert JSON response body structure (checking for keys like id, name, email) beyond just status codes",
"max_score": 8
},
{
"name": "password not in response",
"description": "At least one test verifies that password or password_hash is NOT present in the API response body",
"max_score": 8
}
]
}