smithery/JamesPrial

go-testing-subtests

Subtest patterns with t.Run

Installation

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

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,369 B
  • docs SUMMARY.md 54 B

History

  1. First recorded snapshot · 0 installs

SKILL.md

Subtests with t.Run

Use t.Run to group related tests and enable selective execution.

CORRECT

func Test_User_Validation(t *testing.T) {
    t.Run("valid email", func(t *testing.T) {
        user := User{Email: "[email protected]"}
        if err := user.Validate(); err != nil {
            t.Errorf("expected valid, got error: %v", err)
        }
    })

    t.Run("invalid email", func(t *testing.T) {
        user := User{Email: "invalid"}
        if err := user.Validate(); err == nil {
            t.Error("expected error, got nil")
        }
    })

    t.Run("empty email", func(t *testing.T) {
        user := User{Email: ""}
        if err := user.Validate(); err == nil {
            t.Error("expected error, got nil")
        }
    })
}

Run specific subtest:

go test -run Test_User_Validation/invalid_email

Why:

  • Logical grouping of related tests
  • Can run subtests individually
  • Clean test output with hierarchy
  • Failures don't stop other subtests

WRONG

func Test_User_ValidEmail(t *testing.T) { /* ... */ }
func Test_User_InvalidEmail(t *testing.T) { /* ... */ }
func Test_User_EmptyEmail(t *testing.T) { /* ... */ }

Problems:

  • No grouping relationship
  • Harder to run related tests together
  • More verbose test names