Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Coverage Tooling

This project uses cargo-llvm-cov for code coverage analysis with a >80% coverage threshold.

Setup

Install the coverage tooling dependencies:

just setup

This will install:

  • rustfmt and clippy components
  • cargo-llvm-cov for coverage analysis

Running Coverage

Local Development

# Generate coverage report with 80% threshold
just coverage

# Generate HTML coverage report for local viewing
just coverage-html

# View coverage report in terminal
just coverage-report

The HTML report will be available at target/llvm-cov/html/index.html after running just coverage-html.

CI/CD

The CI system automatically runs coverage analysis:

# CI-friendly coverage (ignores test failures but still generates coverage)
just coverage-ci

Coverage Files

  • lcov.info - Coverage data in LCOV format (uploaded to Codecov)
  • target/llvm-cov/html/ - HTML coverage reports
  • Coverage artifacts are excluded from version control via .gitignore

Coverage Configuration

Included in Coverage

  • Library code (src/lib.rs and modules)
  • Integration tests (tests/)
  • Unit tests (within modules)
  • Doctests (documentation examples)

Excluded from Coverage

  • Benchmarks (benches/) - Automatically excluded as separate targets
  • Generated files
  • Test utilities (helper code in tests/common/)

Thresholds

  • Line Coverage: >80% required (enforced by --fail-under-lines 80)
  • Coverage failures will cause CI builds to fail
  • Use just coverage-ci for CI environments to generate reports even with test failures

Troubleshooting

Coverage Too Low

If coverage drops below 80%:

  1. Add more unit tests for uncovered code
  2. Add integration tests for user-facing functionality
  3. Add doctests for public APIs
  4. Remove dead/unreachable code

View Missing Coverage

just coverage-html
# Open target/llvm-cov/html/index.html in browser

The HTML report shows exactly which lines are not covered.

Clean Coverage Data

just coverage-clean

Commands Reference

CommandDescription
just coverageRun tests with coverage and enforce 80% threshold
just coverage-ciRun coverage for CI (ignores test failures)
just coverage-htmlGenerate HTML coverage report
just coverage-html-ciGenerate HTML coverage report (ignores test failures)
just coverage-reportShow coverage report in terminal
just coverage-cleanClean coverage artifacts
just test-docRun doctests only
just test-unitRun unit tests only
just test-integrationRun integration tests only