PowerShell code coverage orchestrator for Delphi projects, wrapping coverage engines behind a unified interface.
delphi-coverage simplifies running Delphi code coverage analysis. It wraps
coverage engines (DelphiCodeCoverage, radCodeCoverage) with clean parameters,
structured output, threshold enforcement, and badge generation.
Designed for use as a standalone command or as a bundled tool inside delphi-powershell-ci.
If delphi-coverage is on your PATH:
delphi-coverage -Execute test\Win32\Debug\MyApp.Tests.exe `
-MapFile test\Win32\Debug\MyApp.Tests.map -SourceDir source\Otherwise, run it directly:
pwsh -File .\source\delphi-coverage.ps1 -Execute test\Win32\Debug\MyApp.Tests.exe `
-MapFile test\Win32\Debug\MyApp.Tests.map -SourceDir source\Runs on the widely available Windows PowerShell 5.1 (powershell.exe)
and the newer PowerShell 7+ (pwsh).
- Wraps coverage engines behind a unified, documented interface
- Coverage threshold enforcement with exit code 6 on failure
- Badge generation (self-contained SVG or Shields.io JSON endpoint)
- Coverage threshold enforcement -- fail the build if coverage drops below a minimum
- MAP file validation (detects segment-only maps before running)
- Structured JSON output via
-OutputFilefor CI integration - Multiple source directories via comma-separated
-SourceDir
| Engine | Status | Notes |
|---|---|---|
DelphiCodeCoverage |
Supported | Open source, Win32/Win64, MAP-file based |
radCodeCoverage |
Supported | Shares DelphiCodeCoverage CLI conventions, adds markdown, and LCOV output |
CoverageValidator |
Future | Commercial (Software Verify) |
Path to the test executable and its detailed MAP file. Both are required unless -Dproj is used.
delphi-coverage -Execute test\Win32\Debug\MyApp.Tests.exe `
-MapFile test\Win32\Debug\MyApp.Tests.mapPass a .dproj file and the engine auto-discovers the executable, MAP file,
units, and source paths.
When -Dproj is provided, -Execute and -MapFile are not required.
Additional -SourceDir, -Units, and -ExcludeUnits flags supplement
what the engine discovers.
delphi-coverage -Dproj test\MyApp.Tests.dproj
delphi-coverage -Dproj test\MyApp.Tests.dproj -Engine radCodeCoverageWhich coverage engine to use. Default: DelphiCodeCoverage.
The engine executable must be on PATH or specified via -EnginePath.
delphi-coverage -Execute test.exe -MapFile test.map -Engine radCodeCoverageExplicit path to the coverage engine executable. Overrides PATH discovery.
Use this for platform-specific variants (e.g., CodeCoverage.x64.exe or
radCodeCoverage.x64.exe).
delphi-coverage -Execute test.exe -MapFile test.map `
-EnginePath C:\tools\radCodeCoverage.x64.exeDirectories containing Delphi source files, passed as comma-separated
values. Each path gets a separate -sp flag when invoking the engine.
delphi-coverage -Execute test.exe -MapFile test.map -SourceDir source\,lib\Unit name patterns to include in coverage measurement. Supports wildcards.
Comma-separated when passed via -File mode. When empty, all units are
included.
delphi-coverage -Execute test.exe -MapFile test.map -SourceDir source\ `
-Units MyApp.Core.*,MyApp.Utils.*Unit name patterns to exclude from coverage measurement. Comma-separated
when passed via -File mode.
delphi-coverage -Execute test.exe -MapFile test.map -SourceDir source\ `
-Units MyApp.* -ExcludeUnits MyApp.Generated.*Directory for coverage reports. Default: coverage/. Created automatically
if it does not exist.
delphi-coverage -Execute test.exe -MapFile test.map -OutputDir reports\coverageOutput format(s) for coverage reports. Default: html. Comma-separated
when specifying multiple formats.
| Format | Description |
|---|---|
html |
Human-readable HTML report |
xml |
DelphiCodeCoverage XML format |
emma |
Emma XML format |
lcov |
LCOV tracefile format (for Codecov, Coveralls, genhtml) |
cobertura |
Cobertura XML format (for CI tools) |
md |
Markdown coverage report |
delphi-coverage -Execute test.exe -MapFile test.map -Formats html,lcov,mdMinimum coverage percentage required. When set to a value greater than 0, the tool fails (exit code 6) if coverage is below the threshold.
# Fail if coverage drops below 60%
delphi-coverage -Execute test.exe -MapFile test.map -Threshold 60Default: 0 (disabled -- any coverage percentage passes).
Extra command-line arguments passed to the test executable at runtime.
Comma-separated when passed via -File mode.
delphi-coverage -Execute test.exe -MapFile test.map -Arguments -b,-l:WarningMaximum time in seconds for the coverage run. If exceeded, the engine
process is killed and the step fails. Default: 300.
delphi-coverage -Execute test.exe -MapFile test.map -TimeoutSeconds 600Generates a coverage badge file. The output format is determined by the file extension.
Self-contained SVG with no external dependencies. Commit it to the repo or host on GitHub Pages.
delphi-coverage -Execute test.exe -MapFile test.map -Badge docs/coverage-badge.svgREADME usage:
JSON file in Shields.io's endpoint schema. Host it and reference with a dynamic badge URL.
delphi-coverage -Execute test.exe -MapFile test.map -Badge docs/coverage.jsonREADME usage:
| Coverage | Color |
|---|---|
| >= 80% | green |
| >= 60% | yellow |
| < 60% | red |
Path to write a structured JSON result file for CI tool integration.
{
"engine": "radCodeCoverage",
"execute": "test/Win64/Debug/MyApp.Tests.exe",
"exitCode": 0,
"success": true,
"coveragePercent": 73.4,
"linesCovered": 1842,
"linesTotal": 2510,
"threshold": 60,
"thresholdMet": true,
"outputDir": "coverage/",
"formats": ["html", "lcov"],
"badge": "docs/coverage-badge.svg",
"duration": 12.3
} 0 = success: coverage run completed, threshold met (or no threshold set)
1 = unexpected error
2 = invalid arguments (missing params, bad format, segment-only MAP file)
3 = engine executable not found
4 = test executable, MAP file, or .dproj not found
5 = coverage run failed (engine exited non-zero)
6 = threshold not met (coverage below minimum percentage)
delphi-coverage -Execute test\Win32\Debug\MyApp.Tests.exe `
-MapFile test\Win32\Debug\MyApp.Tests.map `
-SourceDir source\delphi-coverage -Dproj test\MyApp.Tests.dproj `
-Engine radCodeCoverage `
-EnginePath radCodeCoverage.x64.exe `
-Formats html,lcov,md `
-Badge assets/coverage/coverage-badge.svgdelphi-coverage -Execute test\Win64\Debug\MyApp.Tests.exe `
-MapFile test\Win64\Debug\MyApp.Tests.map `
-SourceDir source\,lib\,shared\delphi-coverage -Execute test\Win32\Debug\MyApp.Tests.exe `
-MapFile test\Win32\Debug\MyApp.Tests.map `
-SourceDir source\ -Units MyApp.* `
-OutputDir coverage\ -Formats html,lcov `
-Threshold 60delphi-coverage -Execute test\Win32\Debug\MyApp.Tests.exe `
-MapFile test\Win32\Debug\MyApp.Tests.map `
-SourceDir source\ -Badge assets/coverage/coverage-badge.svg{
"pipeline": [
{ "action": "Build", "jobs": [
{ "name": "Test project",
"projectFile": "test/MyApp.Tests.dproj",
"platform": "Win64", "configuration": "Debug",
"defines": ["CI"] }
]},
{ "action": "Coverage", "jobs": [
{ "name": "Unit test coverage",
"dproj": "test/MyApp.Tests.dproj",
"engine": "radCodeCoverage",
"sourceDir": ["/source", "/lib"],
"formats!": ["html", "lcov", "md"],
"threshold": 60,
"badge": "assets/coverage/coverage-badge.svg" }
]}
]
}Coverage requires the test project to be built with:
- Debug information enabled
- Detailed MAP file output (linker setting "Detailed" or
DCC_MapFile=3)
Without these, the coverage engine cannot map execution to source lines.
When using -Dproj mode, the engine reads these settings from the project
file directly.
Requires PowerShell 7+, Pester 5.7+, and PSScriptAnalyzer.
./tests/run-tests.ps1This repository is currently incubator and is under active development.
It will graduate to stable once:
- At least one downstream consumer exists.
Until graduation, breaking changes may occur.
This tool is part of the Continuous-Delphi ecosystem, focused on strengthening Delphi's continued success.

