Skip to content
affaan-m avatar

Golang Testing

Go testing patterns for table-driven tests, subtests, benchmarks, fuzzing, and coverage, following a strict RED-GREEN-REFACTOR TDD cycle.

CCM score
67 of 100
skills.sh installs
16.5K
GitHub stars
312.6K
last updated
Aug 21, 2026
View on GitHub

Own this skill? Claim it

What it does

  • Covers the TDD loop with a worked example: placeholder signature, failing test, minimal implementation, then refactor
  • Includes table-driven tests with error cases, parallel subtests, t.Helper and t.Cleanup helpers, and t.TempDir file handling
  • Adds golden-file testing under testdata/ with an -update flag and interface-based mocking for dependencies
  • Designed for Go developers writing new functions or adding coverage to existing code without a separate test framework

Install

$ npx -y skills add affaan-m/ecc --skill golang-testing -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

Files

Go Testing Patterns

Comprehensive Go testing patterns for writing reliable, maintainable tests following TDD methodology.

When to Activate

  • Writing new Go functions or methods
  • Adding test coverage to existing code
  • Creating benchmarks for performance-critical code
  • Implementing fuzz tests for input validation
  • Following TDD workflow in Go projects

TDD Workflow for Go

The RED-GREEN-REFACTOR Cycle

RED     → Write a failing test first
GREEN   → Write minimal code to pass the test
REFACTOR → Improve code while keeping tests green
REPEAT  → Continue with next requirement

Step-by-Step TDD in Go

// Step 1: Define the interface/signature
// calculator.go
package calculator

func Add(a, b int) int {
    panic("not implemented") // Placeholder
}

// Step 2: Write failing test (RED)
// calculator_test.go
package calculator

import "testing"

func TestAdd(t *testing.T) {
    got := Add(2, 3)
    want := 5
    if got != want {
        t.Errorf("Add(2, 3) = %d; want %d", got, want)
    }
}

// Step 3: Run test - verify FAIL
// $ go test
// --- FAIL: TestAdd (0.00s)
// panic: not implemented

Details

Repository
github.com/affaan-m/ecc
Categories
Testing & QA, Go
First seen
Jul 14, 2026

Questions

What does the golang-testing skill help with?

The golang-testing skill covers Go testing patterns, including table-driven tests, subtests, benchmarks, fuzzing, and test coverage. It follows TDD methodology with idiomatic Go practices, guiding a red-green-refactor cycle.

How do I install the golang-testing skill?

Run npx -y skills add affaan-m/ecc --skill golang-testing -y in your project. Once installed, the agent can write Go table-driven tests, subtests, benchmarks, fuzz tests, and coverage checks.

When should I use the golang-testing skill?

Use it when writing Go tests, such as table-driven cases, subtests, benchmarks, fuzzing, or coverage. It also applies when adding test coverage to existing Go code or following a TDD workflow in a Go project.

Where does golang-testing rank in the Testing and QA category?

The golang-testing skill sits in the Testing and QA category and ranks in the top 50 on its category page. Other skills in the category include tdd, test-driven-development, and webapp-testing.

More from affaan-m/ecc

All 257

Similar to Golang Testing

More Testing & QA