agentleFS
jkeddarijkeddari/go-skills/skills/golang-testing/SKILL.md

golang-testing

Skill1 starsChanged 5 months agoMITView on GitHub

Golang testing strategy using the standard testing package, table-driven tests, subtests, HTTP tests, fuzzing, race detection, coverage, examples, integration boundaries, deterministic concurrency tests, and handwritten test doubles. Use when writing, reviewing, debugging, or organizing Go tests and test suites.

30 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use golang-error-handling, golang-grpc and 5 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • guynhsichngeodiecSkill

    golang-error-handling

    Idiomatic Golang error handling — creation, wrapping with %w, errors.Is/As, errors.Join, custom error types, sentinel errors, panic/recover, the single handling rule, structured logging with slog, HTTP request logging middleware, and samber/oops for production errors. Built to make logs usable at scale with log aggregation 3rd-party tools. Apply when creating, wrapping, inspecting, or logging errors in Go code.

    Also in 6 projects that use this

  • guynhsichngeodiecSkill

    golang-grpc

    Provides gRPC usage guidelines, protobuf organization, and production-ready patterns for Golang microservices. Use when implementing, reviewing, or debugging gRPC servers/clients, writing proto files, setting up interceptors, handling gRPC errors with status codes, configuring TLS/mTLS, testing with bufconn, or working with streaming RPCs.

    Also in 6 projects that use this

  • +5 more from guynhsichngeodiec

The file

We split this skill into the rules it gives an agent

10 rules. 0 are common, 7 are distinctive, and 3 are very specific to this project.

  • 0

    Common

    Most of the 26 edited versions we read keep these.

  • 7

    Distinctive

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Read the public contract and existing tests before choosing cases.

    line 25
  2. Distinctive:

    Use table-driven tests when cases share behavior.

    line 27
  3. Distinctive:

    Prefer focused handwritten fakes at consumer interfaces over mocking frameworks.

    line 28
  4. Very specific:

    Run focused tests first, then go test ./....

    line 30
  5. Distinctive:

    Do not chase coverage percentages at the expense of meaningful assertions.

    line 34
  6. Distinctive:

    Keep tests independent of execution order and global mutable state.

    line 35
  7. Very specific:

    Use t.Cleanup for resources and t.Helper for reusable assertions.

    line 36
  8. Distinctive:

    Use build tags or separate infrastructure for integration tests when they require external services.

    line 37
  9. Very specific:

    Add benchmarks only for explicit performance questions.

    line 39
  10. Distinctive:

    Test command and flag reference: go-test.md

    line 43

“Common” is measured: kept by at least 6 in 10 of the 26 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Persona: You are a Go engineer who treats tests as executable specifications. Test observable behavior and failure contracts rather than implementation details.

Go Testing

Workflow

  1. Read the public contract and existing tests before choosing cases.
  2. Cover success, boundaries, invalid inputs, dependency failures, cancellation, and state transitions that matter.
  3. Use table-driven tests when cases share behavior; use named subtests when they improve diagnosis.
  4. Prefer focused handwritten fakes at consumer interfaces over mocking frameworks.
  5. Make time, randomness, I/O, and concurrency controllable.
  6. Run focused tests first, then go test ./...; add -race for concurrent code.

Principles

  • Do not chase coverage percentages at the expense of meaningful assertions.
  • Keep tests independent of execution order and global mutable state.
  • Use t.Cleanup for resources and t.Helper for reusable assertions.
  • Use build tags or separate infrastructure for integration tests when they require external services.
  • Fuzz parsers, decoders, validators, and boundary-heavy functions with stable invariants.
  • Add benchmarks only for explicit performance questions; interpret them with golang-performance.

Conditional references

  • Test command and flag reference: go-test.md
  • HTTP handlers, clients, and middleware: http-testing.md
  • Timeouts and reusable helpers: helpers.md

Verification

go test ./...
go test -race ./...
go test -run TestName ./path/to/package
go test -fuzz FuzzName ./path/to/package

→ See golang-concurrency for lifecycle invariants, golang-database for database integration tests, and golang-project for CI execution.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.