-
Notifications
You must be signed in to change notification settings - Fork 43
Description
Description
Test helper functions lack t.Helper() calls, causing test failure stack traces to point to helper function internals instead of the actual failing test cases. With 1,394 table-driven tests and complex setup functions, this severely degrades debugging experience and developer productivity.
Currently, only 5 occurrences of t.Helper() exist across the entire test suite. This issue was identified in the Sergo Report #12711.
Impact
Severity: High (developer productivity)
Affected: 100+ test files (estimated)
Problem: Developers waste time navigating from helper internal lines to actual failing test cases when debugging test failures.
Current Pattern (Problematic)
func setupTestEnvironment(t *testing.T) *TestEnv {
// Missing t.Helper() - stack traces show internal lines
tempDir := t.TempDir()
// ... setup code ...
return &TestEnv{Dir: tempDir}
}Correct Pattern
func setupTestEnvironment(t *testing.T) *TestEnv {
t.Helper() // ✅ Marks this as a helper - stack traces show caller
tempDir := t.TempDir()
// ... setup code ...
return &TestEnv{Dir: tempDir}
}Good Examples to Follow
These files already implement the pattern correctly:
pkg/cli/compile_integration_test.go:91pkg/cli/deps_test.go:237,252pkg/cli/mcp_add_integration_test.go:21pkg/cli/audit_report_test.go:55,76,87
Implementation Approach
-
Find candidate functions (semi-automated):
rg "func \w+\(.*\*testing\.T" --type go -g "*_test.go"
-
Add
t.Helper()as first line in each test helper function -
Run tests to verify correct line numbers in failures
-
Add golangci-lint rule to enforce pattern (
thelperlinter)
Success Criteria
- All test helper functions (100+ estimated) have
t.Helper()as first line - Full test suite passes without regressions
- Test failures show correct line numbers (caller, not helper internals)
-
thelperlinter enabled in golangci-lint configuration - Pattern documented in CONTRIBUTING.md
Priority
High - Affects developer productivity across all test debugging sessions.
Estimated Effort
Medium (2-3 hours, semi-automated via ripgrep + manual review)
Source
Extracted from Sergo Report: Table-Driven Test & Init Function Hygiene Analysis #12711
AI generated by Discussion Task Miner - Code Quality Improvement Agent
- expires on Feb 14, 2026, 5:19 AM UTC