Testing Go Code

Run Go unit tests, coverage reports, and benchmarks. Use when you need to run tests, check coverage, run benchmarks, or regenerate mocks after interface changes.

majiayu000 Updated 567 repo stars

File contents

Testing Go Code

All commands run from the Go module root (installer/).

Unit Tests

task test                       # Run all tests with race detection
task test -- -run TestName      # Run specific test(s)
task test -- -short             # Skip integration tests

For test conventions (naming, assertions, table-driven patterns, mock usage), see the writing-go-tests skill.

Coverage

task cov

Runs tests with coverage and opens an HTML report in the browser.

Benchmarks

task bench

Runs all benchmarks with memory allocation stats.

Combined Check

task check

Runs tests + lint in sequence. Use before committing.

Mock Regeneration

mockery

Run from the module root with no arguments after adding or modifying interfaces. Configuration is in .mockery.yml. Never edit generated mock files (*_mock.go) manually.

majiayu000/claude-skill-registry-data/tree/main/testing/testing-go-code commit 18c8423da5

Frequently asked questions

npx skillmds@latest add majiayu000/testing-go-code