-
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 internals instead of actual test cases. With 1,394 table-driven tests and complex setup functions, this severely degrades debugging experience.
Problem
Only 5 occurrences of t.Helper() exist across the entire 1,362-file test suite. When tests fail, stack traces point to internal helper lines instead of the actual test case, wasting developer time navigating to the real failure location.
Good Examples (5 files)
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
Missing (100+ estimated files)
Any function taking *testing.T that performs assertions or setup
Suggested Changes
Audit all test helper functions and add t.Helper() as the first line:
Before
func setupTestEnvironment(t *testing.T) *TestEnv {
// Missing t.Helper()
tempDir := t.TempDir()
// ... setup code ...
return &TestEnv{Dir: tempDir}
}After
func setupTestEnvironment(t *testing.T) *TestEnv {
t.Helper() // ✅ Marks this as a helper
tempDir := t.TempDir()
// ... setup code ...
return &TestEnv{Dir: tempDir}
}Implementation Steps
-
Find candidates - Search for functions taking
*testing.T:rg "func \w+\(.*\*testing\.T" --type go -g "*_test.go"
-
Add t.Helper() - Semi-automated via ripgrep + manual review
-
Enforce pattern - Add golangci-lint
thelperlinter rule -
Document - Add pattern to CONTRIBUTING.md
Files Affected
Estimated 100+ test files across the codebase (any function taking *testing.T)
Success Criteria
- Run full test suite to ensure no regressions
- Manually verify test failures now show correct line numbers
- Add golangci-lint rule to enforce t.Helper() in future
- Document pattern in CONTRIBUTING.md
Source
Extracted from Sergo Report: Table-Driven Test & Init Function Hygiene Analysis - 2026-01-30
Priority
High - Affects developer productivity and debugging experience
Estimated Effort
Medium (2-3 hours) - Semi-automated via ripgrep + manual review
AI generated by Discussion Task Miner - Code Quality Improvement Agent
- expires on Feb 13, 2026, 1:26 PM UTC