Agent skill
go-testing-helpers
Test helper patterns with t.Helper()
Install this agent skill to your Project
npx add-skill https://github.com/JamesPrial/claudefiles/tree/main/skills/golang/testing/helpers
SKILL.md
Test Helpers
Extract common test logic into helper functions with t.Helper().
CORRECT
func assertEqual(t *testing.T, got, want interface{}) {
t.Helper() // Reports caller line, not helper line
if got != want {
t.Errorf("got %v, want %v", got, want)
}
}
func assertNoError(t *testing.T, err error) {
t.Helper()
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
}
func Test_Process(t *testing.T) {
result, err := Process("input")
assertNoError(t, err)
assertEqual(t, result, "expected")
}
Why:
- t.Helper() marks function as helper
- Error reports show caller line, not helper line
- Reduces test boilerplate
- Consistent assertion patterns
WRONG
func assertEqual(t *testing.T, got, want interface{}) {
// Missing t.Helper()
if got != want {
t.Errorf("got %v, want %v", got, want)
}
}
Problems:
- Errors point to helper line
- Hard to find actual test failure
- Confusing stack traces
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
plugin-packager
Package claudefiles components into a valid Claude Code plugin
plugin-packager-validation
Plugin validation errors and fixes
plugin-packager-subset
Package language-specific subsets of claudefiles
plugin-packager-hooks
Handle hook scripts and paths for plugin packaging
go-concurrency
Go concurrency patterns. Routes to specific patterns.
go-sync-primitives
sync.WaitGroup and sync.Mutex patterns
Didn't find tool you were looking for?