Skip to content

Implement suite-test-name checker#293

Open
mmorel-35 wants to merge 1 commit intoAntonboom:masterfrom
mmorel-35:suite-test-name
Open

Implement suite-test-name checker#293
mmorel-35 wants to merge 1 commit intoAntonboom:masterfrom
mmorel-35:suite-test-name

Conversation

@mmorel-35
Copy link
Copy Markdown

@mmorel-35 mmorel-35 commented Mar 13, 2026

Adds the suite-test-name checker that enforces naming consistency between testify suite structs and their runner functions.

Rule

Runner function must be named Test<SuiteName>:

type BalanceSubscriptionSuite struct { suite.Suite }

// ❌ name doesn't match suite
func TestBalanceSubs_Run(t *testing.T) { suite.Run(t, new(BalanceSubscriptionSuite)) }

// ✅
func TestBalanceSubscriptionSuite(t *testing.T) { suite.Run(t, new(BalanceSubscriptionSuite)) }

Supports both new(SuiteName) and &SuiteName{} instantiation forms. Autofix renames the function identifier.

Enabled by default: false — pure style unification
Autofix: true

Changes

  • internal/checkers/suite_test_name.goAdvancedChecker using inspector.WithStack to find suite.Run calls, extract suite type name, and validate the enclosing function name
  • internal/checkers/checkers_registry.go — registered with enabledByDefault: false
  • internal/testgen/gen_suite_test_name.go + internal/testgen/main.go — test generator with errored/golden templates
  • analyzer/testdata/src/checkers-default/suite-test-name/ — generated test data
  • internal/checkers/checkers_registry_test.go, analyzer/checkers_factory_test.go — updated expected checker lists
  • README.md — checker documented in table and checkers section
  • CONTRIBUTING.md — removed from "Open for contribution"

Closes #48

@mmorel-35 mmorel-35 force-pushed the suite-test-name branch 3 times, most recently from c9deed3 to dc26d5b Compare April 9, 2026 18:19
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

suite-naming: enforce consistent suite naming

1 participant