# 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.

- **Type:** Skill
- **Install:** `agentstack add skill-qte77-claude-code-plugins-testing-go`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [qte77](https://agentstack.voostack.com/s/qte77)
- **Installs:** 0
- **Category:** [AI & ML](https://agentstack.voostack.com/c/ai-and-ml)
- **Latest version:** 0.1.0
- **License:** Apache-2.0
- **Upstream author:** [qte77](https://github.com/qte77)
- **Source:** https://github.com/qte77/claude-code-plugins/tree/main/plugins/go-dev/skills/testing-go
- **Website:** https://qte77.github.io/claude-code-plugins/

## Install

```sh
agentstack add skill-qte77-claude-code-plugins-testing-go
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# 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)

```go
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)

```go
func TestValidateEmail(t *testing.T) {
    tests := []struct {
        name    string
        email   string
        wantErr bool
    }{
        {name: "valid", email: "user@example.com", 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}`

```go
TestUserService_Create_ReturnsIDOnSuccess
TestValidateEmail_MissingAt
TestCalculateTotal_EmptyItems
```

## Execution

```bash
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

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [qte77](https://github.com/qte77)
- **Source:** [qte77/claude-code-plugins](https://github.com/qte77/claude-code-plugins)
- **License:** Apache-2.0
- **Homepage:** https://qte77.github.io/claude-code-plugins/

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-qte77-claude-code-plugins-testing-go
- Seller: https://agentstack.voostack.com/s/qte77
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
