CC-301h · Module 3
Test Maintenance
3 min read
Tests rot. A refactored function breaks twenty tests that tested the old interface. A renamed component invalidates snapshot tests. A changed API response format fails integration tests. Test maintenance is the unglamorous work that keeps the test suite trustworthy, and Claude Code handles it efficiently because the work is mechanical — update tests to match the new code, not to test new behavior.
The maintenance prompt pattern: "I refactored the auth module from class-based to function-based. Update all tests in src/auth/ to use the new function signatures. Do not change what the tests are validating — only how they call the code." This constraint is essential. Without it, Claude might simplify or rewrite tests during the update, accidentally removing coverage. The goal is interface migration, not test rewriting.
Do This
- Tell Claude to update test interfaces without changing what is tested
- Run the full test suite after Claude updates tests to verify nothing was lost
- Have Claude identify and remove truly obsolete tests (testing deleted code)
- Use Claude to update snapshot tests after intentional UI changes
Avoid This
- Let Claude rewrite tests during a maintenance pass — it might remove coverage
- Delete failing tests instead of updating them after refactoring
- Accumulate broken tests — a test suite with 20 known failures is a test suite nobody trusts
- Skip test maintenance until the suite is so broken that fixing it is a multi-day project