What problem does it solve?
Writing robust tests in Go can be repetitive and error-prone without established patterns. This Skill consolidates table-driven tests, httptest-based integration tests, and practical mocking patterns to improve test reliability, readability, and maintainability. It also emphasizes a structured approach to organizing unit, handler, database, and concurrent tests, aligning with go-dev and community best practices.
Core Features & Use Cases
- Table-driven tests: standardize test cases in a slice, run them in a loop for comprehensive coverage.
- HTTP/Handler testing: use httptest for end-to-end request/response validation, including error scenarios.
- Mocking & interfaces: depend on interfaces to inject mock implementations and isolate components.
- Concurrency & cancellation: test concurrent workflows and context cancellation to ensure robustness.
- Use Case: validate a service method under normal, error, and edge-case conditions across unit and integration boundaries.
Quick Start
Run go test ./... to execute tests across the module and verify patterns.