agentsclimarketplace

Golang testing

Skill ComeOnOliver/skillshub/skills/HoangNguyen0403/agent-skills-standard/golang-testing

🧠 The right skill, one API call. AI agent skills registry with token-efficient skill resolution. 5,000+ skills from 500+ top repos.

Install
npx -y skills add ComeOnOliver/skillshub --skill golang-testing

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

What its author says it does

Copied from the file, not written here

Standards for unit testing, table-driven tests, and mocking in Golang. Use when writing Go unit tests, table-driven tests, or using mock interfaces. (triggers: **/*_test.go, testing, unit tests, go test, mocking, testify)

SKILL.md

2.0 KB, 464 tokens by cl100k_base, as published. Nobody here has run it

Golang Testing Standards

Priority: P0 (CRITICAL)

Guidelines

TDD & Table-Driven Tests

  • Pattern: Use Table-Driven Tests for multi-input scenarios. Use t.Run() for each test case.
  • Workflow: Follow Red-Green-Refactor. Write a failing test case before implementing logic.
  • Mocking: Use Interfaces and Dependency Injection. Avoid complex mocking frameworks; prefer manual mocks or GoMock.
  • Coverage: Aim for > 80% line coverage. Run go test -cover to audit.
  • Assertions: Use testify/assert or testify/require for readable checks: assert.NoError(t, err).
  • Parallelism: Use t.Parallel() for non-sequential tests to speed up CI.
  • Cleanup: Use t.Cleanup() to reset state or release resources (DB/Files).
  • Subtests: Name each subtest case clearly ("Valid input", "Missing ID", "Network timeout").

Golden Snippet

See Table-Driven Tests for full template.

Tools

  • Stdlib: testing package is usually enough.
  • Testify (stretchr/testify): Assertions (assert, require) and Mocks.
  • Mockery: Auto-generate mocks for interfaces.
  • GoMock: Another popular mocking framework.

Naming

  • Test file: *_test.go
  • Test function: func TestName(t *testing.T)
  • Example function: func ExampleName()

Anti-Patterns

  • No Manual Mocks: Use mockery for boilerplate-heavy mocks.
  • No Assert in Loop: Use t.Run to isolate failures within table-driven loops.
  • No Global Mocks: Define mocks locally or within test scope to avoid state leakage.

References

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.