Back to Skills

go-testing

verified

Go testing practices - unit tests, benchmarks, mocks, coverage

View on GitHub

Marketplace

pluginagentmarketplace-go

pluginagentmarketplace/custom-plugin-go

Plugin

go-development-assistant

Repository

pluginagentmarketplace/custom-plugin-go
3stars

skills/go-testing/SKILL.md

Last Verified

January 21, 2026

Install Skill

Select agents to install to:

Scope:
npx add-skill https://github.com/pluginagentmarketplace/custom-plugin-go/blob/main/skills/go-testing/SKILL.md -a claude-code --skill go-testing

Installation paths:

Claude
.claude/skills/go-testing/
Powered by add-skill CLI

Instructions

# Go Testing Skill

Comprehensive testing strategies for Go applications.

## Overview

Master Go testing including table-driven tests, benchmarks, mocking, fuzzing, and achieving high code coverage.

## Parameters

| Parameter | Type | Required | Default | Description |
|-----------|------|----------|---------|-------------|
| test_type | string | yes | - | Type: "unit", "integration", "benchmark", "fuzz" |
| coverage_min | int | no | 80 | Minimum coverage percentage |
| mock_lib | string | no | "testify" | Mock library: "testify", "gomock" |

## Core Topics

### Table-Driven Tests
```go
func TestParseURL(t *testing.T) {
    tests := []struct {
        name    string
        input   string
        want    *URL
        wantErr bool
    }{
        {
            name:  "valid http",
            input: "http://example.com/path",
            want:  &URL{Scheme: "http", Host: "example.com", Path: "/path"},
        },
        {
            name:    "empty string",
            input:   "",
            wantErr: true,
        },
        {
            name:    "invalid scheme",
            input:   "ftp://example.com",
            wantErr: true,
        },
    }

    for _, tt := range tests {
        t.Run(tt.name, func(t *testing.T) {
            got, err := ParseURL(tt.input)
            if tt.wantErr {
                require.Error(t, err)
                return
            }
            require.NoError(t, err)
            assert.Equal(t, tt.want, got)
        })
    }
}
```

### Mocking
```go
type MockStore struct {
    mock.Mock
}

func (m *MockStore) Get(ctx context.Context, key string) (string, error) {
    args := m.Called(ctx, key)
    return args.String(0), args.Error(1)
}

func TestService_GetValue(t *testing.T) {
    store := new(MockStore)
    store.On("Get", mock.Anything, "key1").Return("value1", nil)

    svc := NewService(store)
    val, err := svc.GetValue(context.Background(), "key1")

    require.NoError(t, err)
    assert.Equal(t, "value1", val)
    stor

Validation Details

Front Matter
Required Fields
Valid Name Format
Valid Description
Has Sections
Allowed Tools
Instruction Length:
3040 chars