Back to list
JamesPrial

go-testing-subtests

by JamesPrial

WIP - collection of various Claude stuff i make/use/have_Claude_hallucinate

2🍴 0📅 Jan 23, 2026

SKILL.md


name: go-testing-subtests description: Subtest patterns with t.Run

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: "test@example.com"}
        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

Score

Total Score

65/100

Based on repository quality metrics

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

+10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

1ヶ月以内に更新

+10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

+5

Reviews

💬

Reviews coming soon