The Coverage Loop: Turning Free AI Tokens into Verified C++ Tests
Description and use
A feedback loop with AI-generated tests achieves high coverage for C++ code.
Problem
Generated tests from free AI models often lack assertions and coverage, leading to ineffective unit tests.
Outcome
The loop reached 90% line coverage for the string utility by iteratively refining AI-generated tests based on coverage feedback.
Workflow
- Send header to AI model asking for tests
- Compile and run the generated tests
- Run gcov to measure line coverage
- Extract missing lines from gcov output
- Feed missing line hints back to the AI and repeat until coverage plateaus
Evidence
Five steps. Each one is small.
The target: a small C++ string utility. The goal: reach 90% line coverage with generated tests.
- Record date: 2026-09-05T14:14:04.267Z