Agent skill
go-test
Generate deterministic Go unit tests using `testutil`, table-driven patterns, and infra mocks with ≥80% coverage.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/go-test
Metadata
Additional technical details for this skill
- short description
- Deterministic Go tests with helpers, mocks, ≥80% coverage.
SKILL.md
Generate Go unit tests for the provided code using Go testing best practices.
Requirements
- Use table-driven tests for all testable functions.
- Use mocking where appropriate:
- Prefer
testify/mockfor interface dependencies. - Avoid real external dependencies (DB, network, filesystem).
- Prefer
- Focus on test coverage, including:
- Success cases
- Error cases
- Edge cases
- Boundary conditions
- Tests must be deterministic and translation-safe (no reliance on time, randomness, or global state unless mocked).
- Follow idiomatic Go conventions:
- File name:
<file>_test.go - Test name:
Test<FunctionName>
- File name:
- Always use English in test names and comments.
- Enforce minimum package coverage of ≥80%.
- Coverage must include:
- At least one error path per public function (if applicable).
- Boundary or edge cases where reasonable.
Output Expectations
- Generate complete, compilable test code.
- Include necessary imports.
- Clearly separate:
- Arrange
- Act
- Assert
- Prefer readability to cleverness.
- Generated tests should realistically achieve ≥80% coverage when executed with:
go test -cover ./...
Additional Guidelines
- Prefer small, focused tests over large monolithic ones.
- If a function is hard to test:
- Explain briefly why
- Suggest a refactor (e.g., dependency injection).
- Do not test private implementation details—test behavior.
- Avoid snapshot-style assertions unless explicitly requested.
- If achieving ≥ 80% coverage is not possible without testing private implementation details:
- Explain the limitation briefly
- Suggest a refactor (interface extraction, dependency injection)
- Avoid fake coverage (e.g. meaningless assertions).
Please Read the References
- Detailed technical reference: REFERENCE.md.
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?