Q18 of 21 · AI for testing
How do you use AI for test maintenance at scale — keeping a large suite current as the application evolves?
Short answer
Short answer: Use AI to identify stale tests (selectors that no longer match the DOM, assertions on removed features), draft updates when you provide the code diff of what changed, and flag tests covering deprecated paths. AI reduces discovery and drafting work; humans approve every change to the assertion logic.
Detail
A 2,000-test suite accumulates maintenance debt quickly: deprecated flows, renamed selectors, changed response shapes. Finding what needs updating is often more expensive than making the actual fix.
AI can help at three points: Discovery: given a code diff from a PR, ask the model which test files likely need updating based on what changed. It catches direct matches reliably while missing indirect dependencies. Draft updates: provide the changed component or API response and the current test, ask for a draft update. Review and correct. Dead code detection: periodically ask AI to identify tests referencing removed elements or deprecated endpoints by cross-referencing against the current codebase.
The anti-pattern to avoid: fully automated test updates without human review. A model that updates assertions to match the new (potentially buggy) behaviour is destroying coverage, not maintaining it. Every AI-drafted maintenance change needs human approval of the business logic, not just the syntax. See AI refactoring for test code.