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
{
"instruction": "Create API tests using httptest with table-driven tests, test helpers, and proper subtests",
"relevant_when": "Agent builds or adds tests to a Go HTTP API",
"context": "Go's standard library httptest provides everything needed for API testing. Tests should follow Go idioms: table-driven tests with t.Run subtests, test helpers with t.Helper(), and httptest.NewRecorder for handler tests.",
"sources": [
{
"type": "file",
"filename": "skills/go-api-testing/SKILL.md",
"tile": "tessl-labs/go-api-testing"
}
],
"checklist": [
{
"name": "test-file-exists",
"rule": "Agent creates *_test.go files with test functions that follow the TestXxx naming convention",
"relevant_when": "Agent builds a Go HTTP API"
},
{
"name": "httptest-used",
"rule": "Agent uses httptest.NewRequest and httptest.NewRecorder (or httptest.NewServer for integration tests) rather than making real HTTP calls",
"relevant_when": "Agent writes Go API tests"
},
{
"name": "table-driven-tests",
"rule": "Agent uses table-driven tests (slice of test structs iterated with for range) with t.Run subtests for testing multiple cases",
"relevant_when": "Agent writes tests for multiple input/output cases"
},
{
"name": "t-helper-in-helpers",
"rule": "Test helper functions call t.Helper() as their first line so failure messages reference the caller",
"relevant_when": "Agent creates test helper functions"
},
{
"name": "error-paths-tested",
"rule": "Tests include at least one 400 (validation) and one 404 (not found) test case, not only happy paths",
"relevant_when": "Agent writes Go API tests"
},
{
"name": "response-body-asserted",
"rule": "Tests assert the response body structure (JSON fields, expected keys) and not just the HTTP status code",
"relevant_when": "Agent writes assertions for API responses"
}
]
}