# Go Testing Helpers

> Test helper patterns with t.Helper() Use when this capability is needed.

- Skill: `tomevault-io/go-testing-helpers` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add tomevault-io/go-testing-helpers`
- Raw SKILL.md: https://api.skillmd.com/api/skills/tomevault-io/go-testing-helpers/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: tomevault-io (https://skillmd.com/u/tomevault-io)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/tomevault-io/go-testing-helpers

---


# Test Helpers

Extract common test logic into helper functions with t.Helper().

## CORRECT

```go
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

```go
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

---
> Converted and distributed by [TomeVault](https://tomevault.io/claim/jamesprial) — claim your Tome and manage your conversions.
<!-- tomevault:4.0:skill_md:2026-04-13 -->

