agentsclimarketplace

Testing go

Skill qte77/claude-code-plugins/plugins/go-dev/skills/testing-go

Writes tests following TDD (using go test, testify, and rapid) best practices. Use when writing unit tests, integration tests, or table-driven tests in Go.From its SKILL.md

Install
npx -y skills add qte77/claude-code-plugins --skill testing-go

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

One thing to look at

  • 2 stars2 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

SKILL.md

3.1 KB, 723 tokens by cl100k_base, as published. Nobody here has run it

Go Testing

Target: $ARGUMENTS

Writes focused, behavior-driven tests following project testing strategy.

Quick Reference

TDD methodology (language-agnostic): See tdd-core plugin (testing-tdd skill)

Go-specific documentation: references/

  • references/testing-strategy.md — Go tools (go test, testify, rapid, gomock)
  • references/tdd-best-practices.md — Go TDD examples (extends tdd-core)

Quick Decision

go test (default): Use table-driven tests for known cases. Works at unit/integration levels.

rapid (edge cases): Use for invariants that must hold for ALL inputs.

See references/testing-strategy.md for full methodology comparison.

TDD Essentials (Quick Reference)

Cycle: RED (failing test / compile error) -> GREEN (minimal pass) -> REFACTOR (clean up)

Structure: Arrange-Act-Assert (AAA)

func TestOrderCalculator_Total_SumsItemPrices(t *testing.T) {
    // ARRANGE
    calc := NewOrderCalculator()
    items := []Item{{Price: 10.00, Qty: 2}, {Price: 5.00, Qty: 1}}

    // ACT
    total := calc.Total(items)

    // ASSERT
    assert.Equal(t, 25.00, total)
}

Table-Driven Tests (Go Idiom)

func TestValidateEmail(t *testing.T) {
    tests := []struct {
        name    string
        email   string
        wantErr bool
    }{
        {name: "valid", email: "[email protected]", wantErr: false},
        {name: "missing @", email: "userexample.com", wantErr: true},
        {name: "empty", email: "", wantErr: true},
    }
    for _, tt := range tests {
        t.Run(tt.name, func(t *testing.T) {
            err := ValidateEmail(tt.email)
            if tt.wantErr {
                require.Error(t, err)
            } else {
                require.NoError(t, err)
            }
        })
    }
}

What to Test (KISS/DRY/YAGNI)

High-Value: Business logic, error paths, integration points, contracts

Avoid: Stdlib behavior, trivial getters, default zero values, type existence

See references/testing-strategy.md -> "Patterns to Remove" for full list.

Naming Convention

Format: Test{Type}_{Method}_{Behavior}

TestUserService_Create_ReturnsIDOnSuccess
TestValidateEmail_MissingAt
TestCalculateTotal_EmptyItems

Execution

go test ./...                           # All tests
go test -run TestUserService ./...      # Filter by name
go test -race ./...                     # Race detector
go test -v -run TestValidateAge ./...   # Verbose single test

Quality Gates

  • All tests pass (go test ./...)
  • TDD Red-Green-Refactor followed
  • Arrange-Act-Assert structure used
  • Table-driven tests for multiple cases
  • Behavior-focused (not implementation)
  • No stdlib behavior tested
  • Interface fakes use var _ Interface = (*fake)(nil) compile check

What ships with it: 2 files

9.4 KB alongside SKILL.md

Keep looking

Skills are one crate of 326,835. 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.