Codecov.io integration for tracking code coverage over time.
Dashboard: https://app.codecov.io/gh/bero/BoldForDelphi
# Set token (once per session)
$env:CODECOV_TOKEN = "your-token-here"
# Run tests with coverage and upload
.\UnitTest\run_coverage.ps1 -UploadThe other options of run_coverage.ps1, and what it needs on the machine, are in
UnitTest/README.md.
| File | Purpose |
|---|---|
UnitTest/Convert-ToCodecovJson.ps1 |
Converts HTML coverage to Codecov JSON format |
UnitTest/codecov.json |
Output file for upload (gitignored) |
UnitTest/codecov.exe |
Codecov uploader (downloaded automatically) |
run_coverage.ps1
│
▼
┌─────────────────────┐
│ Build UnitTest.exe │
│ with MAP file │
└──────────┬──────────┘
│
▼
┌─────────────────────┐
│ DelphiCodeCoverage │
│ runs tests │
└──────────┬──────────┘
│
▼
┌─────────────────────┐ ┌─────────────────────────┐
│ HTML coverage │────▶│ Convert-ToCodecovJson │
│ reports (per file) │ │ .ps1 │
└─────────────────────┘ └───────────┬─────────────┘
│
▼
┌─────────────────────────┐
│ codecov.json │
│ (line-level coverage) │
└───────────┬─────────────┘
│
▼
┌─────────────────────────┐
│ codecov.exe upload │
└───────────┬─────────────┘
│
▼
┌─────────────────────────┐
│ Codecov.io │
│ - Dashboard │
│ - Trend graphs │
│ - PR comments │
│ - Badge │
└─────────────────────────┘
- Never commit the token to git
- Use environment variable
CODECOV_TOKEN - For GitHub Actions, use repository secrets
The uploader is downloaded automatically, or manually:
Invoke-WebRequest -Uri "https://uploader.codecov.io/latest/windows/codecov.exe" -OutFile codecov.exeThe Codecov JSON format requires line-level data. If you see this error:
- Ensure coverage HTML reports exist in
UnitTest/coverage_report/ - Check that source files match paths in the git repository
The converter writes numbers the same way whatever the Windows locale, so a comma as decimal separator does not break the JSON.
- Unit Testing: writing tests
- UnitTest/README.md: running the tests and the coverage locally