AI Test Generation
Qodo Cover (CodiumAI)
CLI Usage
cover-agent \
--source-file-path src/calculator.py \
--test-file-path tests/test_calculator.py \
--code-coverage-report-path coverage.xml \
--test-command "pytest --cov=src --cov-report=xml" \
--coverage-type cobertura \
--desired-coverage 90 \
--max-iterations 5 \
--model gpt-4o
Full Repository Mode
cover-agent-full-repo \
--test-folder tests/ \
--project-root . \
--test-command "pytest --cov=src --cov-report=xml"
GitHub Actions
name: AI Test Coverage
on: [pull_request]
jobs:
coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: qodo-ai/qodo-ci@main
with:
project_language: python
code_coverage_report_path: coverage.xml
test_command: "pytest --cov=src --cov-report=xml"
desired_coverage: 85
Coverage-Driven Approach
- Run existing tests → identify uncovered lines
- Feed uncovered code paths to AI with context
- AI generates targeted tests for uncovered branches
- Validate generated tests compile and pass
- Verify coverage increase, iterate
Copilot Test Generation
/tests Generate unit tests for this function including:
- Happy path scenarios
- Edge cases (null, empty, boundary values)
- Error handling paths
VS 2026: Built-in for .NET (MSTest, xUnit, NUnit) with before/after coverage stats.
Best Practices
- Review AI tests — check for meaningful assertions (not just "runs")
- Use as starting point — refine edge cases manually
- Coverage gates in CI — prevent regression
- Combine with mutation testing — verify test quality
- Include context files —
--included-filesfor related modules