Q11 of 21 · AI for testing
How do you use AI to improve test coverage without generating hundreds of redundant tests?
Short answer
Short answer: Use AI to analyse your existing coverage reports and identify untested paths, then generate targeted tests for those specific gaps — not a broad sweep. Feed the coverage data as context so the model focuses on uncovered branches rather than re-covering happy paths.
Detail
The failure mode of AI-assisted coverage is generation without focus: given "write more tests," a model will produce more tests for the already-well-covered paths because those are the patterns it recognises from your existing suite.
A better workflow:
- Run coverage analysis and identify specific untested branches or uncovered API paths.
- Provide the coverage report and the specific uncovered area to the model: "This branch of the payment handler (lines 142–158) is untested. Write a test that exercises the timeout path."
- Review the generated test against the actual code to verify the assertion is meaningful.
For intelligent test selection — choosing which existing tests to run rather than which new ones to generate — see Coverage prioritisation and Intelligent test selection. These are distinct use cases that AI also supports.