xxxryan

generate-go-tests

1
0
# Install this skill:
npx skills add xxxryan/agent-skills --skill "generate-go-tests"

Install specific skill from multi-skill repository

# Description

Generate table-driven Go tests (unit or integration) for given functions, handlers, or packages. Use when the user asks for tests, coverage, regression prevention, or test scaffolding with mocks/fakes.

# SKILL.md


name: generate-go-tests
description: Generate table-driven Go tests (unit or integration) for given functions, handlers, or packages. Use when the user asks for tests, coverage, regression prevention, or test scaffolding with mocks/fakes.
compatibility: Works with pasted code/diff; best with repo access and go test runnable.
metadata:
short-description: Generate Go tests quickly
allowed-tools: Bash(go:) Bash(git:) Read


Generate Go Tests

Goals

  • Table-driven tests with clear cases
  • Deterministic and parallel-safe tests
  • Minimal mocking; prefer fakes where possible
  • Include edge cases and regression cases

Workflow

  1. Identify what to test
  2. Pure functions: input/output cases
  3. Services: dependency fakes/mocks
  4. HTTP/gRPC handlers: request/response + status codes

  5. Write test structure

  6. TestXxx with []struct{ name ... }
  7. Use subtests: t.Run(tc.name, func(t *testing.T){ ... })
  8. Add t.Parallel() only if safe (no shared mutable state)

  9. Coverage guidance

  10. Include: happy path, validation errors, dependency failure, timeout/cancel
  11. For idempotency: repeated requests, dedup key behavior

Output

  • Provide the full _test.go file content.
  • If dependencies exist, provide minimal fake implementations inline or in a small helper.

Notes

  • Donโ€™t invent functions/types not present. If something is missing, note it and propose the smallest change needed to make testing feasible.

# Supported AI Coding Agents

This skill is compatible with the SKILL.md standard and works with all major AI coding agents:

Learn more about the SKILL.md standard and how to use these skills with your preferred AI coding agent.