MCP HubMCP Hub
SKILL·D68062

go-test-quality

eduardo-sl
업데이트됨 22 days ago
4 조회
68
9
68
GitHub에서 보기
테스팅aitestingdesign

정보

이 스킬은 서브테스트, 목킹, 픽스처, 퍼즈 테스트와 같은 기법을 포함하여 프로덕션급 코드를 위한 Go 테스트 패턴에 대한 포괄적인 지침을 제공합니다. 테스트 작성 또는 개선, 테스트 인프라 설정, 테스트 접근 방식 선택 시 활용하세요. 성능 벤치마킹, 보안 테스트 및 별도 스킬로 제공되는 테이블 기반 테스트 패턴은 명시적으로 제외됩니다.

빠른 설치

Claude Code

추천
기본
npx skills add eduardo-sl/go-agent-skills -a claude-code
플러그인 명령대체
/plugin add https://github.com/eduardo-sl/go-agent-skills
Git 클론대체
git clone https://github.com/eduardo-sl/go-agent-skills.git ~/.claude/skills/go-test-quality

Claude Code에서 이 명령을 복사하여 붙여넣어 스킬을 설치하세요

문서

Go Test Quality

Tests are production code. They run in CI on every commit, they document behavior, and they're the first thing you read when a function breaks at 3am. Write them with the same care you'd give to code that handles money.

Detailed reference material, loaded on demand:

  • references/helpers-and-fixtures.md — test helpers, factory functions with options, t.Cleanup, golden files, mock implementations.
  • references/integration-testing.md — httptest recorder and server, testcontainers, build tags, TestMain, fuzz testing.

Read a reference file only when the summary below is not enough.

1. Test Design Philosophy

Test behavior, not implementation

// ✅ Good — tests what the function DOES
func TestTransferFunds_InsufficientBalance(t *testing.T) {
    from := NewAccount("alice", 100)
    to := NewAccount("bob", 0)

    err := TransferFunds(from, to, 150)

    require.ErrorIs(t, err, ErrInsufficientFunds)
    assert.Equal(t, 100, from.Balance(), "sender balance should be unchanged")
    assert.Equal(t, 0, to.Balance(), "receiver balance should be unchanged")
}

// ❌ Bad — tests HOW the function does it
// asserts debit() was called before credit(), rollback() was called,
// internal mutex was locked — breaks on every refactor

One assertion per logical concept

Multiple assert calls are fine when they verify different facets of the SAME behavior (both accounts after a transfer). A test that checks creation AND update AND deletion is three tests pretending to be one.

Name tests like bug reports

When the test fails, the name alone should say what broke:

// ✅ Good — reads like a sentence
func TestOrderService_Cancel_RefundsPartiallyShippedItems(t *testing.T) { ... }
func TestParseConfig_ReturnsErrorOnMissingRequiredField(t *testing.T) { ... }

// ❌ Bad — says nothing useful
func TestCancel(t *testing.T) { ... }
func TestRateLimiter_Success(t *testing.T) { ... }

2. Subtests for Organized Scenarios

Use t.Run to group related scenarios under a parent test. Each subtest gets its own setup, its own failure, and its own name in CI output:

func TestUserService_Create(t *testing.T) {
    svc := setupUserService(t)

    t.Run("succeeds with valid input", func(t *testing.T) {
        user, err := svc.Create(ctx, CreateUserInput{Name: "Alice", Email: "[email protected]"})
        require.NoError(t, err)
        assert.NotEmpty(t, user.ID)
    })

    t.Run("rejects duplicate email", func(t *testing.T) {
        _, _ = svc.Create(ctx, CreateUserInput{Name: "Alice", Email: "[email protected]"})
        _, err := svc.Create(ctx, CreateUserInput{Name: "Bob", Email: "[email protected]"})
        require.ErrorIs(t, err, ErrDuplicateEmail)
    })
}

3. Test Helper Rules

  1. Always call t.Helper() in test utilities so failures point to the caller, not the helper.
  2. Factory functions with functional options for complex test objects — defaults with per-test overrides, never a 15-parameter constructor.
  3. Prefer t.Cleanup over defer — it runs even after t.FailNow() and is scoped to the test, not the function.

Full implementations in references/helpers-and-fixtures.md.

4. Choosing the Test Type

SituationApproachDetails
Pure function, 3+ data casesTable-driven testgo-test-table-driven skill
HTTP handler in isolationhttptest.NewRecorder + mock storereferences/integration-testing.md
Full routing/middleware stackhttptest.NewServerreferences/integration-testing.md
Real database behaviortestcontainers + build tagsreferences/integration-testing.md
Complex output (JSON, HTML, SQL)Golden files in testdata/references/helpers-and-fixtures.md
Parser/validator on untrusted inputFuzz testreferences/integration-testing.md

5. Mocking Rules

  • Interface-based hand-written mocks for small interfaces (≤3 methods): a struct with function fields plus recorded calls.
  • Function injection for simple seams (now func() time.Time).
  • Do NOT mock: value objects, pure functions, the standard library, or your own code in the same package. Test the real thing.
  • If you mock everything, you're testing your mocks, not your code.

6. Parallelism and Coverage

func TestSlugify(t *testing.T) {
    t.Parallel() // safe: pure function, no shared state
    // ...
}

Do NOT use t.Parallel() when tests share mutable state, databases, files, or process-level state (os.Setenv).

go test -race -coverprofile=coverage.out ./...
go tool cover -func=coverage.out

Targets: business logic 80%+, critical paths (auth, payments) 95%+, handlers 70%+. Don't chase 100% on generated code and simple getters.

Anti-Patterns

  • 🔴 Test with no assertions — always passes, proves nothing
  • 🔴 time.Sleep for synchronization — use channels or polling
  • 🔴 Test depends on execution order — each test must stand alone
  • 🔴 Mocking everything — you end up testing your mocks, not your code
  • 🟡 Test names like Test1, TestSuccess — name the scenario
  • 🟡 Reaching into private fields — test through the public API
  • 🟡 No edge cases: empty, nil, zero, max values, unicode
  • 🟡 Giant shared setup — each test should set up only what it needs
  • 🟢 Fuzz anything that takes untrusted input
  • 🟢 Golden files for complex output comparisons

Verification Checklist

  1. Every test has meaningful assertions (no empty test bodies)
  2. Test names describe the scenario, not the method
  3. t.Helper() called in every test utility function
  4. t.Cleanup() used for resource teardown
  5. t.Parallel() used where safe, avoided where not
  6. Integration tests guarded with testing.Short() or build tags
  7. Mocks are minimal — only mock external dependencies
  8. Edge cases covered: empty, nil, zero, boundary values
  9. go test -race ./... passes
  10. Coverage is meaningful, not just high numbers

GitHub 저장소

eduardo-sl/go-agent-skills
경로: skills/(testing)/go-test-quality
0
FAQ

자주 묻는 질문

go-test-quality Skill이란 무엇인가요?

go-test-quality은(는) eduardo-sl이(가) 만든 Claude Skill입니다. Skill은 Claude가 필요할 때 불러오는 지침과 리소스를 묶어 추가 프롬프트 없이 go-test-quality 관련 작업을 수행할 수 있게 합니다.

go-test-quality은(는) 어떻게 설치하나요?

이 페이지의 설치 명령을 사용하세요. go-test-quality을(를) Claude Code 플러그인으로 추가하거나 저장소를 skills 디렉터리에 복제한 다음 Claude를 다시 시작해 Skill을 불러옵니다.

go-test-quality은(는) 어떤 카테고리에 속하나요?

go-test-quality은(는) 테스팅 카테고리에 속합니다.

go-test-quality은(는) 무료로 사용할 수 있나요?

네. go-test-quality은(는) AIMCP에 등록되어 있으며 무료로 설치할 수 있습니다.

연관 스킬

evaluating-llms-harness
테스팅

이 Claude Skill은 MMLU, GSM8K를 포함한 60개 이상의 표준화된 학술 과제에서 LLM 성능을 벤치마크하기 위해 lm-evaluation-harness를 실행합니다. 개발자들이 모델 품질을 비교하고, 학습 진행 상황을 추적하거나 학술 결과를 보고할 수 있도록 설계되었습니다. 이 도구는 HuggingFace와 vLLM 모델을 포함한 다양한 백엔드를 지원합니다.

스킬 보기
cloudflare-cron-triggers
테스팅

이 스킬은 cron 표현식을 사용하여 Worker를 스케줄링하기 위한 Cloudflare Cron Triggers 구현에 관한 포괄적인 지식을 제공합니다. 주기적 작업, 유지보수 작업, 자동화된 워크플로우 설정 방법을 다루며, 잘못된 cron 표현식이나 시간대 문제 같은 일반적인 이슈들을 해결하는 방법을 포함합니다. 개발자들은 이를 통해 스케줄된 핸들러 구성, cron 트리거 테스트, Workflows 및 Green Compute와의 연동 작업을 수행할 수 있습니다.

스킬 보기
webapp-testing
테스팅

이 Claude Skill은 Python 스크립트를 통해 로컬 웹 애플리케이션을 테스트하기 위한 Playwright 기반 툴킷을 제공합니다. 프론트엔드 검증, UI 디버깅, 스크린샷 캡처, 로그 확인 기능을 지원하며 서버 라이프사이클을 관리합니다. 브라우저 자동화 작업에 사용하되 컨텍스트 오염을 방지하기 위해 소스 코드를 읽지 않고 스크립트를 직접 실행하세요.

스킬 보기
finishing-a-development-branch
테스팅

이 스킬은 테스트 통과를 확인한 후 체계적인 통합 옵션을 제시하여 개발자가 완성된 작업을 마무리하도록 돕습니다. 구현이 완료된 후 머지, PR 생성, 브랜치 정리와 같은 워크플로우를 안내합니다. 코드가 준비되고 테스트가 완료되었을 때 개발 프로세스를 체계적으로 마무리하기 위해 사용하세요.

스킬 보기