[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M732J8MJMX7JG2QW9PZ7XFAT":3,"skill-same:01M732J8MJMX7JG2QW9PZ7XFAT":65},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":44,"commitSha":45,"skillDirectory":46,"forksCount":14,"repositoryHtmlUrl":47,"repositoryHomepageUrl":6,"ownerHtmlUrl":48,"ownerBlogUrl":6,"ownerDescription":49,"updatedAt":50,"install":51,"resources":64},"01M732J8MJMX7JG2QW9PZ7XFAT","golang-testing-strategies",null,"Comprehensive Go testing strategies including table-driven tests, testify assertions, gomock interface mocking, benchmark testing, and CI\u002FCD integration","julio211916\u002FTlantiCAD-Studio-V0.1-alpha","julio211916","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F128201165?v=4","01M730ENY015MHFY82VKR6AGGR","José Carlos amador garcia","01M730ENYT83EWH6EXRHF9FTXV",0,"MIT","https:\u002F\u002Fgithub.com\u002Fjulio211916\u002FTlantiCAD-Studio-V0.1-alpha\u002Fblob\u002Fmain\u002Fskills\u002Fju\u002Fskills\u002Fgolang-testing-strategies\u002FSKILL.md",[],[],"2026-11-11 15:11:14",false,"---\nname: golang-testing-strategies\ndescription: \"Comprehensive Go testing strategies including table-driven tests, testify assertions, gomock interface mocking, benchmark testing, and CI\u002FCD integration\"\nversion: 1.0.0\ncategory: toolchain\nauthor: Claude MPM Team\nlicense: MIT\nprogressive_disclosure:\n  entry_point:\n    summary: \"Master Go testing through table-driven patterns, testify assertions, gomock mocking, benchmarks, and CI integration for production-quality test suites\"\n    when_to_use: \"Writing comprehensive test suites, setting up CI\u002FCD testing pipelines, mocking external dependencies, performance benchmarking critical paths, ensuring race-free concurrent code\"\n    quick_start: \"1. Structure tests with table-driven pattern 2. Use testify for assertions 3. Mock interfaces with gomock 4. Benchmark critical paths 5. Integrate coverage in CI\u002FCD\"\n  token_estimate:\n    entry: 150\n    full: 4500\ncontext_limit: 700\ntags:\n  - testing\n  - golang\n  - testify\n  - gomock\n  - benchmarks\n  - table-driven-tests\nrequires_tools: []\n---\n\n# Go Testing Strategies\n\n## Overview\n\nGo provides a robust built-in testing framework (`testing` package) that emphasizes simplicity and developer productivity. Combined with community tools like testify and gomock, Go testing enables comprehensive test coverage with minimal boilerplate.\n\n**Key Features:**\n- 📋 **Table-Driven Tests**: Idiomatic pattern for testing multiple inputs\n- ✅ **Testify**: Readable assertions and test suites\n- 🎭 **Gomock**: Type-safe interface mocking\n- ⚡ **Benchmarking**: Built-in performance testing\n- 🔍 **Race Detector**: Concurrent code safety verification\n- 📊 **Coverage**: Native coverage reporting and enforcement\n- 🚀 **CI Integration**: Test caching and parallel execution\n\n## When to Use This Skill\n\nActivate this skill when:\n- Writing test suites for Go libraries or applications\n- Setting up testing infrastructure for new projects\n- Mocking external dependencies (databases, APIs, services)\n- Benchmarking performance-critical code paths\n- Ensuring thread-safe concurrent implementations\n- Integrating tests into CI\u002FCD pipelines\n- Migrating from other testing frameworks\n\n## Core Testing Principles\n\n### The Go Testing Philosophy\n\n1. **Simplicity Over Magic**: Use standard library when possible\n2. **Table-Driven Tests**: Test multiple scenarios with single function\n3. **Subtests**: Organize related tests with `t.Run()`\n4. **Interface-Based Mocking**: Mock dependencies through interfaces\n5. **Test Files Colocate**: Place `*_test.go` files alongside code\n6. **Package Naming**: Use `package_test` for external tests, `package` for internal\n\n### Test Organization\n\n**File Naming Convention:**\n- Unit tests: `file_test.go`\n- Integration tests: `file_integration_test.go`\n- Benchmark tests: Prefix with `Benchmark` in same test file\n\n**Package Structure:**\n```\nmypackage\u002F\n├── user.go\n├── user_test.go              \u002F\u002F Internal tests (same package)\n├── user_external_test.go     \u002F\u002F External tests (package mypackage_test)\n├── integration_test.go       \u002F\u002F Integration tests\n└── testdata\u002F                 \u002F\u002F Test fixtures (ignored by go build)\n    └── golden.json\n```\n\n## Table-Driven Test Pattern\n\n### Basic Structure\n\nThe idiomatic Go testing pattern for testing multiple inputs:\n\n```go\nfunc TestUserValidation(t *testing.T) {\n    tests := []struct {\n        name    string\n        input   User\n        wantErr bool\n        errMsg  string\n    }{\n        {\n            name:    \"valid user\",\n            input:   User{Name: \"Alice\", Age: 30, Email: \"alice@example.com\"},\n            wantErr: false,\n        },\n        {\n            name:    \"empty name\",\n            input:   User{Name: \"\", Age: 30, Email: \"alice@example.com\"},\n            wantErr: true,\n            errMsg:  \"name is required\",\n        },\n        {\n            name:    \"invalid email\",\n            input:   User{Name: \"Bob\", Age: 25, Email: \"invalid\"},\n            wantErr: true,\n            errMsg:  \"invalid email format\",\n        },\n        {\n            name:    \"negative age\",\n            input:   User{Name: \"Charlie\", Age: -5, Email: \"charlie@example.com\"},\n            wantErr: true,\n            errMsg:  \"age must be positive\",\n        },\n    }\n\n    for _, tt := range tests {\n        t.Run(tt.name, func(t *testing.T) {\n            err := ValidateUser(tt.input)\n\n            if (err != nil) != tt.wantErr {\n                t.Errorf(\"ValidateUser() error = %v, wantErr %v\", err, tt.wantErr)\n                return\n            }\n\n            if tt.wantErr && err.Error() != tt.errMsg {\n                t.Errorf(\"ValidateUser() error message = %v, want %v\", err.Error(), tt.errMsg)\n            }\n        })\n    }\n}\n```\n\n### Parallel Test Execution\n\nEnable parallel test execution for independent tests:\n\n```go\nfunc TestConcurrentOperations(t *testing.T) {\n    tests := []struct {\n        name string\n        fn   func() int\n        want int\n    }{\n        {\"operation 1\", func() int { return compute1() }, 42},\n        {\"operation 2\", func() int { return compute2() }, 84},\n        {\"operation 3\", func() int { return compute3() }, 126},\n    }\n\n    for _, tt := range tests {\n        tt := tt \u002F\u002F Capture range variable\n        t.Run(tt.name, func(t *testing.T) {\n            t.Parallel() \u002F\u002F Run tests concurrently\n\n            got := tt.fn()\n            if got != tt.want {\n                t.Errorf(\"got %v, want %v\", got, tt.want)\n            }\n        })\n    }\n}\n```\n\n## Testify Framework\n\n### Installation\n\n```bash\ngo get github.com\u002Fstretchr\u002Ftestify\n```\n\n### Assertions\n\nReplace verbose error checking with readable assertions:\n\n```go\nimport (\n    \"testing\"\n    \"github.com\u002Fstretchr\u002Ftestify\u002Fassert\"\n    \"github.com\u002Fstretchr\u002Ftestify\u002Frequire\"\n)\n\nfunc TestCalculator(t *testing.T) {\n    calc := NewCalculator()\n\n    \u002F\u002F assert: Test continues on failure\n    assert.Equal(t, 5, calc.Add(2, 3))\n    assert.NotNil(t, calc)\n    assert.True(t, calc.IsReady())\n\n    \u002F\u002F require: Test stops on failure (for critical assertions)\n    result, err := calc.Divide(10, 2)\n    require.NoError(t, err) \u002F\u002F Stop if error occurs\n    assert.Equal(t, 5, result)\n}\n\nfunc TestUserOperations(t *testing.T) {\n    user := &User{ID: 1, Name: \"Alice\", Email: \"alice@example.com\"}\n\n    \u002F\u002F Object matching\n    assert.Equal(t, 1, user.ID)\n    assert.Contains(t, user.Email, \"@\")\n    assert.Len(t, user.Name, 5)\n\n    \u002F\u002F Partial matching\n    assert.ObjectsAreEqual(user, &User{\n        ID:    1,\n        Name:  \"Alice\",\n        Email: assert.AnythingOfType(\"string\"),\n    })\n}\n```\n\n### Test Suites\n\nOrganize related tests with setup\u002Fteardown:\n\n```go\nimport (\n    \"testing\"\n    \"github.com\u002Fstretchr\u002Ftestify\u002Fsuite\"\n)\n\ntype UserServiceTestSuite struct {\n    suite.Suite\n    db      *sql.DB\n    service *UserService\n}\n\n\u002F\u002F SetupSuite runs once before all tests\nfunc (s *UserServiceTestSuite) SetupSuite() {\n    s.db = setupTestDatabase()\n    s.service = NewUserService(s.db)\n}\n\n\u002F\u002F TearDownSuite runs once after all tests\nfunc (s *UserServiceTestSuite) TearDownSuite() {\n    s.db.Close()\n}\n\n\u002F\u002F SetupTest runs before each test\nfunc (s *UserServiceTestSuite) SetupTest() {\n    cleanDatabase(s.db)\n}\n\n\u002F\u002F TearDownTest runs after each test\nfunc (s *UserServiceTestSuite) TearDownTest() {\n    \u002F\u002F Cleanup if needed\n}\n\n\u002F\u002F Test methods must start with \"Test\"\nfunc (s *UserServiceTestSuite) TestCreateUser() {\n    user := &User{Name: \"Alice\", Email: \"alice@example.com\"}\n\n    err := s.service.Create(user)\n    s.NoError(err)\n    s.NotEqual(0, user.ID) \u002F\u002F ID assigned\n}\n\nfunc (s *UserServiceTestSuite) TestGetUser() {\n    \u002F\u002F Setup\n    user := &User{Name: \"Bob\", Email: \"bob@example.com\"}\n    s.service.Create(user)\n\n    \u002F\u002F Test\n    retrieved, err := s.service.GetByID(user.ID)\n    s.NoError(err)\n    s.Equal(user.Name, retrieved.Name)\n}\n\n\u002F\u002F Run the suite\nfunc TestUserServiceTestSuite(t *testing.T) {\n    suite.Run(t, new(UserServiceTestSuite))\n}\n```\n\n## Gomock Interface Mocking\n\n### Installation\n\n```bash\ngo install github.com\u002Fgolang\u002Fmock\u002Fmockgen@latest\n```\n\n### Generate Mocks\n\n```go\n\u002F\u002F user_repository.go\npackage repository\n\n\u002F\u002Fgo:generate mockgen -source=user_repository.go -destination=mocks\u002Fmock_user_repository.go -package=mocks\n\ntype UserRepository interface {\n    GetByID(id int) (*User, error)\n    Create(user *User) error\n    Update(user *User) error\n    Delete(id int) error\n}\n```\n\nGenerate mocks:\n```bash\ngo generate .\u002F...\n# Or manually:\nmockgen -source=user_repository.go -destination=mocks\u002Fmock_user_repository.go -package=mocks\n```\n\n### Using Mocks in Tests\n\n```go\nimport (\n    \"testing\"\n    \"github.com\u002Fgolang\u002Fmock\u002Fgomock\"\n    \"github.com\u002Fstretchr\u002Ftestify\u002Fassert\"\n    \"myapp\u002Frepository\u002Fmocks\"\n)\n\nfunc TestUserService_GetUser(t *testing.T) {\n    ctrl := gomock.NewController(t)\n    defer ctrl.Finish()\n\n    \u002F\u002F Create mock\n    mockRepo := mocks.NewMockUserRepository(ctrl)\n\n    \u002F\u002F Set expectations\n    expectedUser := &User{ID: 1, Name: \"Alice\"}\n    mockRepo.EXPECT().\n        GetByID(1).\n        Return(expectedUser, nil).\n        Times(1)\n\n    \u002F\u002F Test\n    service := NewUserService(mockRepo)\n    user, err := service.GetUser(1)\n\n    \u002F\u002F Assertions\n    assert.NoError(t, err)\n    assert.Equal(t, expectedUser, user)\n}\n\nfunc TestUserService_CreateUser_Validation(t *testing.T) {\n    ctrl := gomock.NewController(t)\n    defer ctrl.Finish()\n\n    mockRepo := mocks.NewMockUserRepository(ctrl)\n\n    \u002F\u002F Expect Create to NOT be called (validation should fail first)\n    mockRepo.EXPECT().Create(gomock.Any()).Times(0)\n\n    service := NewUserService(mockRepo)\n    err := service.CreateUser(&User{Name: \"\"}) \u002F\u002F Invalid user\n\n    assert.Error(t, err)\n    assert.Contains(t, err.Error(), \"name is required\")\n}\n```\n\n### Custom Matchers\n\n```go\n\u002F\u002F Custom matcher for complex validation\ntype userMatcher struct {\n    expectedEmail string\n}\n\nfunc (m userMatcher) Matches(x interface{}) bool {\n    user, ok := x.(*User)\n    if !ok {\n        return false\n    }\n    return user.Email == m.expectedEmail\n}\n\nfunc (m userMatcher) String() string {\n    return \"matches user with email: \" + m.expectedEmail\n}\n\nfunc UserWithEmail(email string) gomock.Matcher {\n    return userMatcher{expectedEmail: email}\n}\n\n\u002F\u002F Usage in test\nfunc TestCustomMatcher(t *testing.T) {\n    ctrl := gomock.NewController(t)\n    defer ctrl.Finish()\n\n    mockRepo := mocks.NewMockUserRepository(ctrl)\n\n    mockRepo.EXPECT().\n        Create(UserWithEmail(\"alice@example.com\")).\n        Return(nil)\n\n    service := NewUserService(mockRepo)\n    service.CreateUser(&User{Name: \"Alice\", Email: \"alice@example.com\"})\n}\n```\n\n## Benchmark Testing\n\n### Basic Benchmarks\n\n```go\nfunc BenchmarkAdd(b *testing.B) {\n    calc := NewCalculator()\n\n    for i := 0; i \u003C b.N; i++ {\n        calc.Add(2, 3)\n    }\n}\n\nfunc BenchmarkStringConcatenation(b *testing.B) {\n    b.Run(\"plus operator\", func(b *testing.B) {\n        for i := 0; i \u003C b.N; i++ {\n            _ = \"hello\" + \"world\"\n        }\n    })\n\n    b.Run(\"strings.Builder\", func(b *testing.B) {\n        for i := 0; i \u003C b.N; i++ {\n            var sb strings.Builder\n            sb.WriteString(\"hello\")\n            sb.WriteString(\"world\")\n            _ = sb.String()\n        }\n    })\n}\n```\n\n### Running Benchmarks\n\n```bash\n# Run all benchmarks\ngo test -bench=.\n\n# Run specific benchmark\ngo test -bench=BenchmarkAdd\n\n# With memory allocation stats\ngo test -bench=. -benchmem\n\n# Compare benchmarks\ngo test -bench=. -benchmem > old.txt\n# Make changes\ngo test -bench=. -benchmem > new.txt\nbenchstat old.txt new.txt\n```\n\n### Benchmark Output Example\n\n```\nBenchmarkAdd-8                  1000000000      0.25 ns\u002Fop      0 B\u002Fop      0 allocs\u002Fop\nBenchmarkStringBuilder-8        50000000        28.5 ns\u002Fop      64 B\u002Fop     1 allocs\u002Fop\n```\n\nReading: `50000000` iterations, `28.5 ns\u002Fop` per operation, `64 B\u002Fop` bytes allocated per op, `1 allocs\u002Fop` allocations per op\n\n## Advanced Testing Patterns\n\n### httptest for HTTP Handlers\n\n```go\nimport (\n    \"net\u002Fhttp\"\n    \"net\u002Fhttp\u002Fhttptest\"\n    \"testing\"\n)\n\nfunc TestUserHandler(t *testing.T) {\n    handler := http.HandlerFunc(UserHandler)\n\n    req := httptest.NewRequest(\"GET\", \"\u002Fusers\u002F1\", nil)\n    rec := httptest.NewRecorder()\n\n    handler.ServeHTTP(rec, req)\n\n    assert.Equal(t, http.StatusOK, rec.Code)\n    assert.Contains(t, rec.Body.String(), \"Alice\")\n}\n\nfunc TestHTTPClient(t *testing.T) {\n    \u002F\u002F Mock server\n    server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n        assert.Equal(t, \"\u002Fapi\u002Fusers\", r.URL.Path)\n        w.WriteHeader(http.StatusOK)\n        w.Write([]byte(`{\"id\": 1, \"name\": \"Alice\"}`))\n    }))\n    defer server.Close()\n\n    \u002F\u002F Test client against mock server\n    client := NewAPIClient(server.URL)\n    user, err := client.GetUser(1)\n\n    assert.NoError(t, err)\n    assert.Equal(t, \"Alice\", user.Name)\n}\n```\n\n### Race Detector\n\nDetect data races in concurrent code:\n\n```bash\ngo test -race .\u002F...\n```\n\nExample test for concurrent safety:\n\n```go\nfunc TestConcurrentMapAccess(t *testing.T) {\n    cache := NewSafeCache()\n\n    var wg sync.WaitGroup\n    for i := 0; i \u003C 100; i++ {\n        wg.Add(1)\n        go func(val int) {\n            defer wg.Done()\n            cache.Set(fmt.Sprintf(\"key%d\", val), val)\n        }(i)\n    }\n\n    wg.Wait()\n    assert.Equal(t, 100, cache.Len())\n}\n```\n\n### Golden File Testing\n\nTest against expected output files:\n\n```go\nfunc TestRenderTemplate(t *testing.T) {\n    output := RenderTemplate(\"user\", User{Name: \"Alice\"})\n\n    goldenFile := \"testdata\u002Fuser_template.golden\"\n\n    if *update {\n        \u002F\u002F Update golden file: go test -update\n        os.WriteFile(goldenFile, []byte(output), 0644)\n    }\n\n    expected, err := os.ReadFile(goldenFile)\n    require.NoError(t, err)\n\n    assert.Equal(t, string(expected), output)\n}\n\nvar update = flag.Bool(\"update\", false, \"update golden files\")\n```\n\n## CI\u002FCD Integration\n\n### GitHub Actions Example\n\n```yaml\n# .github\u002Fworkflows\u002Ftest.yml\nname: Tests\n\non: [push, pull_request]\n\njobs:\n  test:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions\u002Fcheckout@v3\n\n      - name: Set up Go\n        uses: actions\u002Fsetup-go@v4\n        with:\n          go-version: '1.23'\n\n      - name: Run tests\n        run: go test -v -race -coverprofile=coverage.out .\u002F...\n\n      - name: Upload coverage\n        uses: codecov\u002Fcodecov-action@v3\n        with:\n          files: .\u002Fcoverage.out\n\n      - name: Check coverage threshold\n        run: |\n          go tool cover -func=coverage.out | grep total | awk '{print $3}' | sed 's\u002F%\u002F\u002F' | \\\n          awk '{if ($1 \u003C 80) exit 1}'\n```\n\n### Coverage Enforcement\n\n```bash\n# Generate coverage report\ngo test -coverprofile=coverage.out .\u002F...\n\n# View coverage in terminal\ngo tool cover -func=coverage.out\n\n# Generate HTML report\ngo tool cover -html=coverage.out -o coverage.html\n\n# Check coverage threshold (fail if \u003C 80%)\ngo test -coverprofile=coverage.out .\u002F... && \\\ngo tool cover -func=coverage.out | grep total | awk '{if (substr($3, 1, length($3)-1) \u003C 80) exit 1}'\n```\n\n## Decision Trees\n\n### When to Use Each Testing Tool\n\n**Use Standard `testing` Package When:**\n- Simple unit tests with few assertions\n- No external dependencies to mock\n- Performance benchmarking\n- Minimal dependencies preferred\n\n**Use Testify When:**\n- Need readable assertions (`assert.Equal` vs verbose checks)\n- Test suites with setup\u002Fteardown\n- Multiple similar test cases\n- Prefer expressive test code\n\n**Use Gomock When:**\n- Testing code with interface dependencies\n- Need precise call verification (times, order)\n- Complex mock behavior with multiple scenarios\n- Type-safe mocking required\n\n**Use Benchmarks When:**\n- Optimizing performance-critical code\n- Comparing algorithm implementations\n- Detecting performance regressions\n- Memory allocation profiling\n\n**Use httptest When:**\n- Testing HTTP handlers\n- Mocking external HTTP APIs\n- Integration testing HTTP clients\n- Testing middleware chains\n\n**Use Race Detector When:**\n- Writing concurrent code\n- Using goroutines and channels\n- Shared state across goroutines\n- CI\u002FCD for all concurrent code\n\n## Anti-Patterns to Avoid\n\n❌ **Don't Mock Everything**\n```go\n\u002F\u002F WRONG: Over-mocking makes tests brittle\nmockLogger := mocks.NewMockLogger(ctrl)\nmockConfig := mocks.NewMockConfig(ctrl)\nmockMetrics := mocks.NewMockMetrics(ctrl)\n\u002F\u002F Too many mocks = fragile test\n```\n\n✅ **Do: Mock Only External Dependencies**\n```go\n\u002F\u002F CORRECT: Mock only database, use real logger\u002Fconfig\nmockRepo := mocks.NewMockUserRepository(ctrl)\nservice := NewUserService(mockRepo, realLogger, realConfig)\n```\n\n❌ **Don't Test Implementation Details**\n```go\n\u002F\u002F WRONG: Testing internal state\nassert.Equal(t, \"processing\", service.internalState)\n```\n\n✅ **Do: Test Public Behavior**\n```go\n\u002F\u002F CORRECT: Test observable outcomes\nuser, err := service.GetUser(1)\nassert.NoError(t, err)\nassert.Equal(t, \"Alice\", user.Name)\n```\n\n❌ **Don't Ignore Error Cases**\n```go\n\u002F\u002F WRONG: Only testing happy path\nfunc TestGetUser(t *testing.T) {\n    user, _ := service.GetUser(1) \u002F\u002F Ignoring error!\n    assert.NotNil(t, user)\n}\n```\n\n✅ **Do: Test Error Conditions**\n```go\n\u002F\u002F CORRECT: Test both success and error cases\nfunc TestGetUser_NotFound(t *testing.T) {\n    user, err := service.GetUser(999)\n    assert.Error(t, err)\n    assert.Nil(t, user)\n    assert.Contains(t, err.Error(), \"not found\")\n}\n```\n\n## Best Practices\n\n1. **Colocate Tests**: Place `*_test.go` files alongside source code\n2. **Use Subtests**: Organize related tests with `t.Run()`\n3. **Parallel When Safe**: Enable `t.Parallel()` for independent tests\n4. **Mock Interfaces**: Design for testability with interface dependencies\n5. **Test Errors**: Verify both success and failure paths\n6. **Benchmark Critical Paths**: Profile performance-sensitive code\n7. **Run Race Detector**: Always use `-race` for concurrent code\n8. **Enforce Coverage**: Set minimum thresholds in CI (typically 80%)\n9. **Use Golden Files**: Test complex outputs with expected files\n10. **Keep Tests Fast**: Mock slow operations, use `-short` flag for quick runs\n\n## Resources\n\n**Official Documentation:**\n- Go Testing Package: https:\u002F\u002Fpkg.go.dev\u002Ftesting\n- Table-Driven Tests: https:\u002F\u002Fgithub.com\u002Fgolang\u002Fgo\u002Fwiki\u002FTableDrivenTests\n- Subtests and Sub-benchmarks: https:\u002F\u002Fgo.dev\u002Fblog\u002Fsubtests\n\n**Testing Frameworks:**\n- Testify: https:\u002F\u002Fgithub.com\u002Fstretchr\u002Ftestify\n- Gomock: https:\u002F\u002Fgithub.com\u002Fgolang\u002Fmock\n- httptest: https:\u002F\u002Fpkg.go.dev\u002Fnet\u002Fhttp\u002Fhttptest\n\n**Recent Guides (2025):**\n- \"Go Unit Testing: Structure & Best Practices\" (November 2025)\n- Go Wiki: CommonMistakes in Testing\n- Google Go Style Guide - Testing: https:\u002F\u002Fgoogle.github.io\u002Fstyleguide\u002Fgo\u002F\n\n**Related Skills:**\n- **golang-engineer**: Core Go patterns and concurrency\n- **verification-before-completion**: Testing as part of \"done\"\n- **testing-anti-patterns**: Avoid common testing mistakes\n\n## Quick Reference\n\n### Run Tests\n```bash\ngo test .\u002F...                    # All tests\ngo test -v .\u002F...                 # Verbose output\ngo test -short .\u002F...             # Skip slow tests\ngo test -run TestUserCreate      # Specific test\ngo test -race .\u002F...              # With race detector\ngo test -cover .\u002F...             # With coverage\ngo test -coverprofile=c.out .\u002F... # Coverage file\ngo test -bench=. -benchmem       # Benchmarks with memory\n```\n\n### Generate Mocks\n```bash\ngo generate .\u002F...                           # All \u002F\u002Fgo:generate directives\nmockgen -source=interface.go -destination=mock.go\n```\n\n### Coverage Analysis\n```bash\ngo tool cover -func=coverage.out           # Coverage per function\ngo tool cover -html=coverage.out           # HTML report\n```\n\n---\n\n**Token Estimate**: ~4,500 tokens (entry point + full content)\n**Version**: 1.0.0\n**Last Updated**: 2025-12-03\n","# Go Testing Strategies\n\n## Overview\n\nGo provides a robust built-in testing framework (`testing` package) that emphasizes simplicity and developer productivity. Combined with community tools like testify and gomock, Go testing enables comprehensive test coverage with minimal boilerplate.\n\n**Key Features:**\n- 📋 **Table-Driven Tests**: Idiomatic pattern for testing multiple inputs\n- ✅ **Testify**: Readable assertions and test suites\n- 🎭 **Gomock**: Type-safe interface mocking\n- ⚡ **Benchmarking**: Built-in performance testing\n- 🔍 **Race Detector**: Concurrent code safety verification\n- 📊 **Coverage**: Native coverage reporting and enforcement\n- 🚀 **CI Integration**: Test caching and parallel execution\n\n## When to Use This Skill\n\nActivate this skill when:\n- Writing test suites for Go libraries or applications\n- Setting up testing infrastructure for new projects\n- Mocking external dependencies (databases, APIs, services)\n- Benchmarking performance-critical code paths\n- Ensuring thread-safe concurrent implementations\n- Integrating tests into CI\u002FCD pipelines\n- Migrating from other testing frameworks\n\n## Core Testing Principles\n\n### The Go Testing Philosophy\n\n1. **Simplicity Over Magic**: Use standard library when possible\n2. **Table-Driven Tests**: Test multiple scenarios with single function\n3. **Subtests**: Organize related tests with `t.Run()`\n4. **Interface-Based Mocking**: Mock dependencies through interfaces\n5. **Test Files Colocate**: Place `*_test.go` files alongside code\n6. **Package Naming**: Use `package_test` for external tests, `package` for internal\n\n### Test Organization\n\n**File Naming Convention:**\n- Unit tests: `file_test.go`\n- Integration tests: `file_integration_test.go`\n- Benchmark tests: Prefix with `Benchmark` in same test file\n\n**Package Structure:**\n```\nmypackage\u002F\n├── user.go\n├── user_test.go              \u002F\u002F Internal tests (same package)\n├── user_external_test.go     \u002F\u002F External tests (package mypackage_test)\n├── integration_test.go       \u002F\u002F Integration tests\n└── testdata\u002F                 \u002F\u002F Test fixtures (ignored by go build)\n    └── golden.json\n```\n\n## Table-Driven Test Pattern\n\n### Basic Structure\n\nThe idiomatic Go testing pattern for testing multiple inputs:\n\n```go\nfunc TestUserValidation(t *testing.T) {\n    tests := []struct {\n        name    string\n        input   User\n        wantErr bool\n        errMsg  string\n    }{\n        {\n            name:    \"valid user\",\n            input:   User{Name: \"Alice\", Age: 30, Email: \"alice@example.com\"},\n            wantErr: false,\n        },\n        {\n            name:    \"empty name\",\n            input:   User{Name: \"\", Age: 30, Email: \"alice@example.com\"},\n            wantErr: true,\n            errMsg:  \"name is required\",\n        },\n        {\n            name:    \"invalid email\",\n            input:   User{Name: \"Bob\", Age: 25, Email: \"invalid\"},\n            wantErr: true,\n            errMsg:  \"invalid email format\",\n        },\n        {\n            name:    \"negative age\",\n            input:   User{Name: \"Charlie\", Age: -5, Email: \"charlie@example.com\"},\n            wantErr: true,\n            errMsg:  \"age must be positive\",\n        },\n    }\n\n    for _, tt := range tests {\n        t.Run(tt.name, func(t *testing.T) {\n            err := ValidateUser(tt.input)\n\n            if (err != nil) != tt.wantErr {\n                t.Errorf(\"ValidateUser() error = %v, wantErr %v\", err, tt.wantErr)\n                return\n            }\n\n            if tt.wantErr && err.Error() != tt.errMsg {\n                t.Errorf(\"ValidateUser() error message = %v, want %v\", err.Error(), tt.errMsg)\n            }\n        })\n    }\n}\n```\n\n### Parallel Test Execution\n\nEnable parallel test execution for independent tests:\n\n```go\nfunc TestConcurrentOperations(t *testing.T) {\n    tests := []struct {\n        name string\n        fn   func() int\n        want int\n    }{\n        {\"operation 1\", func() int { return compute1() }, 42},\n        {\"operation 2\", func() int { return compute2() }, 84},\n        {\"operation 3\", func() int { return compute3() }, 126},\n    }\n\n    for _, tt := range tests {\n        tt := tt \u002F\u002F Capture range variable\n        t.Run(tt.name, func(t *testing.T) {\n            t.Parallel() \u002F\u002F Run tests concurrently\n\n            got := tt.fn()\n            if got != tt.want {\n                t.Errorf(\"got %v, want %v\", got, tt.want)\n            }\n        })\n    }\n}\n```\n\n## Testify Framework\n\n### Installation\n\n```bash\ngo get github.com\u002Fstretchr\u002Ftestify\n```\n\n### Assertions\n\nReplace verbose error checking with readable assertions:\n\n```go\nimport (\n    \"testing\"\n    \"github.com\u002Fstretchr\u002Ftestify\u002Fassert\"\n    \"github.com\u002Fstretchr\u002Ftestify\u002Frequire\"\n)\n\nfunc TestCalculator(t *testing.T) {\n    calc := NewCalculator()\n\n    \u002F\u002F assert: Test continues on failure\n    assert.Equal(t, 5, calc.Add(2, 3))\n    assert.NotNil(t, calc)\n    assert.True(t, calc.IsReady())\n\n    \u002F\u002F require: Test stops on failure (for critical assertions)\n    result, err := calc.Divide(10, 2)\n    require.NoError(t, err) \u002F\u002F Stop if error occurs\n    assert.Equal(t, 5, result)\n}\n\nfunc TestUserOperations(t *testing.T) {\n    user := &User{ID: 1, Name: \"Alice\", Email: \"alice@example.com\"}\n\n    \u002F\u002F Object matching\n    assert.Equal(t, 1, user.ID)\n    assert.Contains(t, user.Email, \"@\")\n    assert.Len(t, user.Name, 5)\n\n    \u002F\u002F Partial matching\n    assert.ObjectsAreEqual(user, &User{\n        ID:    1,\n        Name:  \"Alice\",\n        Email: assert.AnythingOfType(\"string\"),\n    })\n}\n```\n\n### Test Suites\n\nOrganize related tests with setup\u002Fteardown:\n\n```go\nimport (\n    \"testing\"\n    \"github.com\u002Fstretchr\u002Ftestify\u002Fsuite\"\n)\n\ntype UserServiceTestSuite struct {\n    suite.Suite\n    db      *sql.DB\n    service *UserService\n}\n\n\u002F\u002F SetupSuite runs once before all tests\nfunc (s *UserServiceTestSuite) SetupSuite() {\n    s.db = setupTestDatabase()\n    s.service = NewUserService(s.db)\n}\n\n\u002F\u002F TearDownSuite runs once after all tests\nfunc (s *UserServiceTestSuite) TearDownSuite() {\n    s.db.Close()\n}\n\n\u002F\u002F SetupTest runs before each test\nfunc (s *UserServiceTestSuite) SetupTest() {\n    cleanDatabase(s.db)\n}\n\n\u002F\u002F TearDownTest runs after each test\nfunc (s *UserServiceTestSuite) TearDownTest() {\n    \u002F\u002F Cleanup if needed\n}\n\n\u002F\u002F Test methods must start with \"Test\"\nfunc (s *UserServiceTestSuite) TestCreateUser() {\n    user := &User{Name: \"Alice\", Email: \"alice@example.com\"}\n\n    err := s.service.Create(user)\n    s.NoError(err)\n    s.NotEqual(0, user.ID) \u002F\u002F ID assigned\n}\n\nfunc (s *UserServiceTestSuite) TestGetUser() {\n    \u002F\u002F Setup\n    user := &User{Name: \"Bob\", Email: \"bob@example.com\"}\n    s.service.Create(user)\n\n    \u002F\u002F Test\n    retrieved, err := s.service.GetByID(user.ID)\n    s.NoError(err)\n    s.Equal(user.Name, retrieved.Name)\n}\n\n\u002F\u002F Run the suite\nfunc TestUserServiceTestSuite(t *testing.T) {\n    suite.Run(t, new(UserServiceTestSuite))\n}\n```\n\n## Gomock Interface Mocking\n\n### Installation\n\n```bash\ngo install github.com\u002Fgolang\u002Fmock\u002Fmockgen@latest\n```\n\n### Generate Mocks\n\n```go\n\u002F\u002F user_repository.go\npackage repository\n\n\u002F\u002Fgo:generate mockgen -source=user_repository.go -destination=mocks\u002Fmock_user_repository.go -package=mocks\n\ntype UserRepository interface {\n    GetByID(id int) (*User, error)\n    Create(user *User) error\n    Update(user *User) error\n    Delete(id int) error\n}\n```\n\nGenerate mocks:\n```bash\ngo generate .\u002F...\n# Or manually:\nmockgen -source=user_repository.go -destination=mocks\u002Fmock_user_repository.go -package=mocks\n```\n\n### Using Mocks in Tests\n\n```go\nimport (\n    \"testing\"\n    \"github.com\u002Fgolang\u002Fmock\u002Fgomock\"\n    \"github.com\u002Fstretchr\u002Ftestify\u002Fassert\"\n    \"myapp\u002Frepository\u002Fmocks\"\n)\n\nfunc TestUserService_GetUser(t *testing.T) {\n    ctrl := gomock.NewController(t)\n    defer ctrl.Finish()\n\n    \u002F\u002F Create mock\n    mockRepo := mocks.NewMockUserRepository(ctrl)\n\n    \u002F\u002F Set expectations\n    expectedUser := &User{ID: 1, Name: \"Alice\"}\n    mockRepo.EXPECT().\n        GetByID(1).\n        Return(expectedUser, nil).\n        Times(1)\n\n    \u002F\u002F Test\n    service := NewUserService(mockRepo)\n    user, err := service.GetUser(1)\n\n    \u002F\u002F Assertions\n    assert.NoError(t, err)\n    assert.Equal(t, expectedUser, user)\n}\n\nfunc TestUserService_CreateUser_Validation(t *testing.T) {\n    ctrl := gomock.NewController(t)\n    defer ctrl.Finish()\n\n    mockRepo := mocks.NewMockUserRepository(ctrl)\n\n    \u002F\u002F Expect Create to NOT be called (validation should fail first)\n    mockRepo.EXPECT().Create(gomock.Any()).Times(0)\n\n    service := NewUserService(mockRepo)\n    err := service.CreateUser(&User{Name: \"\"}) \u002F\u002F Invalid user\n\n    assert.Error(t, err)\n    assert.Contains(t, err.Error(), \"name is required\")\n}\n```\n\n### Custom Matchers\n\n```go\n\u002F\u002F Custom matcher for complex validation\ntype userMatcher struct {\n    expectedEmail string\n}\n\nfunc (m userMatcher) Matches(x interface{}) bool {\n    user, ok := x.(*User)\n    if !ok {\n        return false\n    }\n    return user.Email == m.expectedEmail\n}\n\nfunc (m userMatcher) String() string {\n    return \"matches user with email: \" + m.expectedEmail\n}\n\nfunc UserWithEmail(email string) gomock.Matcher {\n    return userMatcher{expectedEmail: email}\n}\n\n\u002F\u002F Usage in test\nfunc TestCustomMatcher(t *testing.T) {\n    ctrl := gomock.NewController(t)\n    defer ctrl.Finish()\n\n    mockRepo := mocks.NewMockUserRepository(ctrl)\n\n    mockRepo.EXPECT().\n        Create(UserWithEmail(\"alice@example.com\")).\n        Return(nil)\n\n    service := NewUserService(mockRepo)\n    service.CreateUser(&User{Name: \"Alice\", Email: \"alice@example.com\"})\n}\n```\n\n## Benchmark Testing\n\n### Basic Benchmarks\n\n```go\nfunc BenchmarkAdd(b *testing.B) {\n    calc := NewCalculator()\n\n    for i := 0; i \u003C b.N; i++ {\n        calc.Add(2, 3)\n    }\n}\n\nfunc BenchmarkStringConcatenation(b *testing.B) {\n    b.Run(\"plus operator\", func(b *testing.B) {\n        for i := 0; i \u003C b.N; i++ {\n            _ = \"hello\" + \"world\"\n        }\n    })\n\n    b.Run(\"strings.Builder\", func(b *testing.B) {\n        for i := 0; i \u003C b.N; i++ {\n            var sb strings.Builder\n            sb.WriteString(\"hello\")\n            sb.WriteString(\"world\")\n            _ = sb.String()\n        }\n    })\n}\n```\n\n### Running Benchmarks\n\n```bash\n# Run all benchmarks\ngo test -bench=.\n\n# Run specific benchmark\ngo test -bench=BenchmarkAdd\n\n# With memory allocation stats\ngo test -bench=. -benchmem\n\n# Compare benchmarks\ngo test -bench=. -benchmem > old.txt\n# Make changes\ngo test -bench=. -benchmem > new.txt\nbenchstat old.txt new.txt\n```\n\n### Benchmark Output Example\n\n```\nBenchmarkAdd-8                  1000000000      0.25 ns\u002Fop      0 B\u002Fop      0 allocs\u002Fop\nBenchmarkStringBuilder-8        50000000        28.5 ns\u002Fop      64 B\u002Fop     1 allocs\u002Fop\n```\n\nReading: `50000000` iterations, `28.5 ns\u002Fop` per operation, `64 B\u002Fop` bytes allocated per op, `1 allocs\u002Fop` allocations per op\n\n## Advanced Testing Patterns\n\n### httptest for HTTP Handlers\n\n```go\nimport (\n    \"net\u002Fhttp\"\n    \"net\u002Fhttp\u002Fhttptest\"\n    \"testing\"\n)\n\nfunc TestUserHandler(t *testing.T) {\n    handler := http.HandlerFunc(UserHandler)\n\n    req := httptest.NewRequest(\"GET\", \"\u002Fusers\u002F1\", nil)\n    rec := httptest.NewRecorder()\n\n    handler.ServeHTTP(rec, req)\n\n    assert.Equal(t, http.StatusOK, rec.Code)\n    assert.Contains(t, rec.Body.String(), \"Alice\")\n}\n\nfunc TestHTTPClient(t *testing.T) {\n    \u002F\u002F Mock server\n    server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n        assert.Equal(t, \"\u002Fapi\u002Fusers\", r.URL.Path)\n        w.WriteHeader(http.StatusOK)\n        w.Write([]byte(`{\"id\": 1, \"name\": \"Alice\"}`))\n    }))\n    defer server.Close()\n\n    \u002F\u002F Test client against mock server\n    client := NewAPIClient(server.URL)\n    user, err := client.GetUser(1)\n\n    assert.NoError(t, err)\n    assert.Equal(t, \"Alice\", user.Name)\n}\n```\n\n### Race Detector\n\nDetect data races in concurrent code:\n\n```bash\ngo test -race .\u002F...\n```\n\nExample test for concurrent safety:\n\n```go\nfunc TestConcurrentMapAccess(t *testing.T) {\n    cache := NewSafeCache()\n\n    var wg sync.WaitGroup\n    for i := 0; i \u003C 100; i++ {\n        wg.Add(1)\n        go func(val int) {\n            defer wg.Done()\n            cache.Set(fmt.Sprintf(\"key%d\", val), val)\n        }(i)\n    }\n\n    wg.Wait()\n    assert.Equal(t, 100, cache.Len())\n}\n```\n\n### Golden File Testing\n\nTest against expected output files:\n\n```go\nfunc TestRenderTemplate(t *testing.T) {\n    output := RenderTemplate(\"user\", User{Name: \"Alice\"})\n\n    goldenFile := \"testdata\u002Fuser_template.golden\"\n\n    if *update {\n        \u002F\u002F Update golden file: go test -update\n        os.WriteFile(goldenFile, []byte(output), 0644)\n    }\n\n    expected, err := os.ReadFile(goldenFile)\n    require.NoError(t, err)\n\n    assert.Equal(t, string(expected), output)\n}\n\nvar update = flag.Bool(\"update\", false, \"update golden files\")\n```\n\n## CI\u002FCD Integration\n\n### GitHub Actions Example\n\n```yaml\n# .github\u002Fworkflows\u002Ftest.yml\nname: Tests\n\non: [push, pull_request]\n\njobs:\n  test:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions\u002Fcheckout@v3\n\n      - name: Set up Go\n        uses: actions\u002Fsetup-go@v4\n        with:\n          go-version: '1.23'\n\n      - name: Run tests\n        run: go test -v -race -coverprofile=coverage.out .\u002F...\n\n      - name: Upload coverage\n        uses: codecov\u002Fcodecov-action@v3\n        with:\n          files: .\u002Fcoverage.out\n\n      - name: Check coverage threshold\n        run: |\n          go tool cover -func=coverage.out | grep total | awk '{print $3}' | sed 's\u002F%\u002F\u002F' | \\\n          awk '{if ($1 \u003C 80) exit 1}'\n```\n\n### Coverage Enforcement\n\n```bash\n# Generate coverage report\ngo test -coverprofile=coverage.out .\u002F...\n\n# View coverage in terminal\ngo tool cover -func=coverage.out\n\n# Generate HTML report\ngo tool cover -html=coverage.out -o coverage.html\n\n# Check coverage threshold (fail if \u003C 80%)\ngo test -coverprofile=coverage.out .\u002F... && \\\ngo tool cover -func=coverage.out | grep total | awk '{if (substr($3, 1, length($3)-1) \u003C 80) exit 1}'\n```\n\n## Decision Trees\n\n### When to Use Each Testing Tool\n\n**Use Standard `testing` Package When:**\n- Simple unit tests with few assertions\n- No external dependencies to mock\n- Performance benchmarking\n- Minimal dependencies preferred\n\n**Use Testify When:**\n- Need readable assertions (`assert.Equal` vs verbose checks)\n- Test suites with setup\u002Fteardown\n- Multiple similar test cases\n- Prefer expressive test code\n\n**Use Gomock When:**\n- Testing code with interface dependencies\n- Need precise call verification (times, order)\n- Complex mock behavior with multiple scenarios\n- Type-safe mocking required\n\n**Use Benchmarks When:**\n- Optimizing performance-critical code\n- Comparing algorithm implementations\n- Detecting performance regressions\n- Memory allocation profiling\n\n**Use httptest When:**\n- Testing HTTP handlers\n- Mocking external HTTP APIs\n- Integration testing HTTP clients\n- Testing middleware chains\n\n**Use Race Detector When:**\n- Writing concurrent code\n- Using goroutines and channels\n- Shared state across goroutines\n- CI\u002FCD for all concurrent code\n\n## Anti-Patterns to Avoid\n\n❌ **Don't Mock Everything**\n```go\n\u002F\u002F WRONG: Over-mocking makes tests brittle\nmockLogger := mocks.NewMockLogger(ctrl)\nmockConfig := mocks.NewMockConfig(ctrl)\nmockMetrics := mocks.NewMockMetrics(ctrl)\n\u002F\u002F Too many mocks = fragile test\n```\n\n✅ **Do: Mock Only External Dependencies**\n```go\n\u002F\u002F CORRECT: Mock only database, use real logger\u002Fconfig\nmockRepo := mocks.NewMockUserRepository(ctrl)\nservice := NewUserService(mockRepo, realLogger, realConfig)\n```\n\n❌ **Don't Test Implementation Details**\n```go\n\u002F\u002F WRONG: Testing internal state\nassert.Equal(t, \"processing\", service.internalState)\n```\n\n✅ **Do: Test Public Behavior**\n```go\n\u002F\u002F CORRECT: Test observable outcomes\nuser, err := service.GetUser(1)\nassert.NoError(t, err)\nassert.Equal(t, \"Alice\", user.Name)\n```\n\n❌ **Don't Ignore Error Cases**\n```go\n\u002F\u002F WRONG: Only testing happy path\nfunc TestGetUser(t *testing.T) {\n    user, _ := service.GetUser(1) \u002F\u002F Ignoring error!\n    assert.NotNil(t, user)\n}\n```\n\n✅ **Do: Test Error Conditions**\n```go\n\u002F\u002F CORRECT: Test both success and error cases\nfunc TestGetUser_NotFound(t *testing.T) {\n    user, err := service.GetUser(999)\n    assert.Error(t, err)\n    assert.Nil(t, user)\n    assert.Contains(t, err.Error(), \"not found\")\n}\n```\n\n## Best Practices\n\n1. **Colocate Tests**: Place `*_test.go` files alongside source code\n2. **Use Subtests**: Organize related tests with `t.Run()`\n3. **Parallel When Safe**: Enable `t.Parallel()` for independent tests\n4. **Mock Interfaces**: Design for testability with interface dependencies\n5. **Test Errors**: Verify both success and failure paths\n6. **Benchmark Critical Paths**: Profile performance-sensitive code\n7. **Run Race Detector**: Always use `-race` for concurrent code\n8. **Enforce Coverage**: Set minimum thresholds in CI (typically 80%)\n9. **Use Golden Files**: Test complex outputs with expected files\n10. **Keep Tests Fast**: Mock slow operations, use `-short` flag for quick runs\n\n## Resources\n\n**Official Documentation:**\n- Go Testing Package: https:\u002F\u002Fpkg.go.dev\u002Ftesting\n- Table-Driven Tests: https:\u002F\u002Fgithub.com\u002Fgolang\u002Fgo\u002Fwiki\u002FTableDrivenTests\n- Subtests and Sub-benchmarks: https:\u002F\u002Fgo.dev\u002Fblog\u002Fsubtests\n\n**Testing Frameworks:**\n- Testify: https:\u002F\u002Fgithub.com\u002Fstretchr\u002Ftestify\n- Gomock: https:\u002F\u002Fgithub.com\u002Fgolang\u002Fmock\n- httptest: https:\u002F\u002Fpkg.go.dev\u002Fnet\u002Fhttp\u002Fhttptest\n\n**Recent Guides (2025):**\n- \"Go Unit Testing: Structure & Best Practices\" (November 2025)\n- Go Wiki: CommonMistakes in Testing\n- Google Go Style Guide - Testing: https:\u002F\u002Fgoogle.github.io\u002Fstyleguide\u002Fgo\u002F\n\n**Related Skills:**\n- **golang-engineer**: Core Go patterns and concurrency\n- **verification-before-completion**: Testing as part of \"done\"\n- **testing-anti-patterns**: Avoid common testing mistakes\n\n## Quick Reference\n\n### Run Tests\n```bash\ngo test .\u002F...                    # All tests\ngo test -v .\u002F...                 # Verbose output\ngo test -short .\u002F...             # Skip slow tests\ngo test -run TestUserCreate      # Specific test\ngo test -race .\u002F...              # With race detector\ngo test -cover .\u002F...             # With coverage\ngo test -coverprofile=c.out .\u002F... # Coverage file\ngo test -bench=. -benchmem       # Benchmarks with memory\n```\n\n### Generate Mocks\n```bash\ngo generate .\u002F...                           # All \u002F\u002Fgo:generate directives\nmockgen -source=interface.go -destination=mock.go\n```\n\n### Coverage Analysis\n```bash\ngo tool cover -func=coverage.out           # Coverage per function\ngo tool cover -html=coverage.out           # HTML report\n```\n\n---\n\n**Token Estimate**: ~4,500 tokens (entry point + full content)\n**Version**: 1.0.0\n**Last Updated**: 2025-12-03\n",{"name":5,"tags":24,"author":31,"license":15,"version":32,"category":33,"description":7,"context_limit":34,"requires_tools":35,"progressive_disclosure":36},[25,26,27,28,29,30],"testing","golang","testify","gomock","benchmarks","table-driven-tests","Claude MPM Team","1.0.0","toolchain",700,[],{"entry_point":37,"token_estimate":41},{"summary":38,"quick_start":39,"when_to_use":40},"Master Go testing through table-driven patterns, testify assertions, gomock mocking, benchmarks, and CI integration for production-quality test suites","1. Structure tests with table-driven pattern 2. Use testify for assertions 3. Mock interfaces with gomock 4. Benchmark critical paths 5. Integrate coverage in CI\u002FCD","Writing comprehensive test suites, setting up CI\u002FCD testing pipelines, mocking external dependencies, performance benchmarking critical paths, ensuring race-free concurrent code",{"full":42,"entry":43},4500,150,"main","590aa4fe05d1ec71a02ee9cc76c9a20508b5bcea","skills\u002Fju\u002Fskills\u002Fgolang-testing-strategies","https:\u002F\u002Fgithub.com\u002Fjulio211916\u002FTlantiCAD-Studio-V0.1-alpha","https:\u002F\u002Fgithub.com\u002Fjulio211916","Estudiante de ing sistemas y psicologia","2026-05-22 04:43:54",{"source":8,"skillName":5,"commands":52,"prompt":62,"zipAvailable":63},[53,56,59],{"tool":54,"command":55},"npx","npx skills add julio211916\u002FTlantiCAD-Studio-V0.1-alpha --skill golang-testing-strategies",{"tool":57,"command":58},"bunx","bunx skills add julio211916\u002FTlantiCAD-Studio-V0.1-alpha --skill golang-testing-strategies",{"tool":60,"command":61},"pnpm","pnpm dlx skills add julio211916\u002FTlantiCAD-Studio-V0.1-alpha --skill golang-testing-strategies","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fjulio211916\u002FTlantiCAD-Studio-V0.1-alpha\u002Fblob\u002Fmain\u002Fskills\u002Fju\u002Fskills\u002Fgolang-testing-strategies\u002FSKILL.md",true,[],[66,73,80,87,94,101],{"skillNo":67,"name":68,"nameZh":6,"description":69,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":70,"categories":71,"keywords":72,"publishedAt":19},"01M735PMP7K29TEC1BC5A3VJ3Z","simpy","Process-based discrete-event simulation framework in Python. Use this skill when building simulations of systems with processes, queues, resources, and time-based events such as manufacturing systems, service operations, network traffic, logistics, or any system where entities interact with shared resources over time.","https:\u002F\u002Fgithub.com\u002Fjulio211916\u002FTlantiCAD-Studio-V0.1-alpha\u002Fblob\u002Fmain\u002Fskills\u002Fju\u002Fskills\u002Fsimpy\u002FSKILL.md",[],[],{"skillNo":74,"name":75,"nameZh":6,"description":76,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":77,"categories":78,"keywords":79,"publishedAt":19},"01M735NX56AZHYMV3BQ8GYZ7J0","shopify-expert","Builds and debugs Shopify themes (.liquid files, theme.json, sections), develops custom Shopify apps (shopify.app.toml, OAuth, webhooks), and implements Storefront API integrations for headless storefronts. Use when building or customizing Shopify themes, creating Hydrogen or custom React storefronts, developing Shopify apps, implementing checkout UI extensions or Shopify Functions, optimizing performance, or integrating third-party services. Invoke for Liquid templating, Storefront API, app development, checkout customization, Shopify Plus features, App Bridge, Polaris, or Shopify CLI workflows.","https:\u002F\u002Fgithub.com\u002Fjulio211916\u002FTlantiCAD-Studio-V0.1-alpha\u002Fblob\u002Fmain\u002Fskills\u002Fju\u002Fskills\u002Fshopify-expert\u002FSKILL.md",[],[],{"skillNo":81,"name":82,"nameZh":6,"description":83,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":84,"categories":85,"keywords":86,"publishedAt":19},"01M735N9WTN69TVA2T5VS9W1CA","shap","Model interpretability and explainability using SHAP (SHapley Additive exPlanations). Use this skill when explaining machine learning model predictions, computing feature importance, generating SHAP plots (waterfall, beeswarm, bar, scatter, force, heatmap), debugging models, analyzing model bias or fairness, comparing models, or implementing explainable AI. Works with tree-based models (XGBoost, LightGBM, Random Forest), deep learning (TensorFlow, PyTorch), linear models, and any black-box model.","https:\u002F\u002Fgithub.com\u002Fjulio211916\u002FTlantiCAD-Studio-V0.1-alpha\u002Fblob\u002Fmain\u002Fskills\u002Fju\u002Fskills\u002Fshap\u002FSKILL.md",[],[],{"skillNo":88,"name":89,"nameZh":6,"description":90,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":91,"categories":92,"keywords":93,"publishedAt":19},"01M735N3VQ8R56TXFF16BMF19H","shadcn-ui","Deep expertise on shadcn\u002Fui component library including installation, customization, theming, and accessibility patterns. Use when building UI with shadcn\u002Fui components, integrating Radix UI primitives, configuring Tailwind CSS v4 themes, or implementing dark mode. Covers Next.js App Router, Pages Router, and Vite setups.","https:\u002F\u002Fgithub.com\u002Fjulio211916\u002FTlantiCAD-Studio-V0.1-alpha\u002Fblob\u002Fmain\u002Fskills\u002Fju\u002Fskills\u002Fshadcn-ui\u002FSKILL.md",[],[],{"skillNo":95,"name":96,"nameZh":6,"description":97,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":98,"categories":99,"keywords":100,"publishedAt":19},"01M735KH64KS6Z58H6BJWX89BV","seoul-subway-arrival","Look up Seoul real-time subway arrival information with the official Seoul Open Data API. Use when the user asks when a train arrives, which trains are approaching a station, or how crowded Seoul subway timing looks right now.","https:\u002F\u002Fgithub.com\u002Fjulio211916\u002FTlantiCAD-Studio-V0.1-alpha\u002Fblob\u002Fmain\u002Fskills\u002Fju\u002Fskills\u002Fseoul-subway-arrival\u002FSKILL.md",[],[],{"skillNo":102,"name":103,"nameZh":6,"description":104,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":105,"categories":106,"keywords":107,"publishedAt":19},"01M735K7KAFBZNACQ66PMDQMQD","seo-optimization","Comprehensive 7-phase SEO optimization workflow covering technical SEO auditing, keyword research strategy, on-page optimization, content SEO and E-E-A-T, structured data implementation, link building, and AI search optimization. Use when auditing search engine visibility, diagnosing ranking issues, implementing schema markup, conducting keyword research, optimizing content for E-E-A-T signals, or adapting for AI-driven search (AI Overviews, SGE).","https:\u002F\u002Fgithub.com\u002Fjulio211916\u002FTlantiCAD-Studio-V0.1-alpha\u002Fblob\u002Fmain\u002Fskills\u002Fju\u002Fskills\u002Fseo-optimization\u002FSKILL.md",[],[]]