smithery/JamesPrial

go-testing-helpers

Test helper patterns with t.Helper()

Installation

$ npx skills add smithery/JamesPrial --skill go-testing-helpers

Similar popular skills

Related neighbors and high-traction skills in the same topics — useful to compare before installing.

Also in this package

Other skills from smithery/JamesPrial · top by installs.

npx skills add smithery/JamesPrial

Browse all from smithery/JamesPrial

More details

Agent compatibility

Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.

Claude Code Not declared
Cursor Not declared
Codex Not declared
GitHub Copilot Not declared
Windsurf Not declared
Gemini CLI Not declared
Cline Not declared
OpenCode Not declared

Package contents

Files included with this skill beyond the listing page.

  • skill md SKILL.md 1,091 B
  • docs SUMMARY.md 62 B

History

  1. First recorded snapshot · 0 installs

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