Skip to content

Measure code coverage of the end-to-end suite - #9

Merged
dkgs2000 merged 1 commit into
mainfrom
claude/nostalgic-sammet-80ff3e
Nov 26, 2026
Merged

dkgs2000 merged 1 commit into
mainfrom
claude/nostalgic-sammet-80ff3e

Conversation

@dkgs2000

Copy link
Copy Markdown
Owner

Measures which code of the service the end-to-end suite runs, and shows it next to the unit tests' coverage on the run's page. With unit tests only, CloudSyncEngine.cs showed 4.6% of its lines run, because the end-to-end suite is what tests it.

How

  • E2E-Run.ps1 and E2E-Run-Mock.ps1 take -Coverage, which is off by default. After the build, they instrument OpenCfDrive.Core.dll and the service's own DLL with Microsoft's dotnet-coverage and run a collector beside the run. At the end, the collector writes coverage.cobertura.xml to the temp root and the scripts put the plain DLLs back.
  • Why dotnet-coverage and not coverlet: the scripts always end the service by killing it, and --stop kills too. Coverlet writes its hits when a process exits, so it would get nothing. With dotnet-coverage, instrumented code writes its hits into memory shared with the collector, so they survive the kill. Every service process of the run counts, including the restart and the --unregister calls.
  • Supply chain: the tool is pinned (18.12.0) in .config/dotnet-tools.json. Dependabot's NuGet updates read that file, so the 7-day cooldown applies. The tool's telemetry is turned off. No new service is involved.
  • CI: the four E2E jobs run with -Coverage and keep their report in their logs artifact. A new Code coverage job runs after the others, even when one failed, and combines all the reports on the run's page. For each assembly it shows the lines run by the unit tests, by the E2E suite, and by either. Then it lists the files with the most lines no test runs.
  • Coverage-Summary.ps1 combines several reports file by file and line by line: a line counts as run if any report ran it. Name=path gives a group of reports its own column. Microsoft's reports have no branch data, so the combined table shows lines only.
  • There's no threshold: coverage only reports. docs/testing.md explains it all.

Tested locally

Run Without coverage With coverage Scenarios
mock, WebDAV 144 s 138–160 s 27 passed, 41 skipped
mock, S3 – 146 s 27 passed, 41 skipped
cloud, WebDAV 421 s 386–424 s 68 passed

Measuring adds about 3 s per run. The unit tests (coverlet 10.1.0): 281 passed. Cloud mode on S3 wasn't run locally; it runs here on CI.

Unit and E2E coverage combined on this PC: OpenCfDrive.Core 82.9% of lines (unit tests alone: 58.8%), CloudSyncEngine.cs 76.3% (unit tests alone: 4.6%).

🤖 Generated with Claude Code

E2E-Run.ps1 and E2E-Run-Mock.ps1 take -Coverage: after the build they
instrument OpenCfDrive.Core.dll and the service's own DLL with Microsoft's
dotnet-coverage (pinned in .config/dotnet-tools.json, which Dependabot's
NuGet updates cover) and run a collector beside the run. Instrumented code
writes its hits into memory shared with the collector, so they survive the
service being killed, which is how the scripts always end it. Every service
process of the run counts. At the end the collector writes
coverage.cobertura.xml to the temp root and the plain DLLs go back. The
tool's telemetry is turned off. It adds about 3 s to a run.

CI runs the four E2E jobs with -Coverage and keeps each report with the
logs. A new Code coverage job, after the others, combines them with the
unit tests' report on the run's page: lines run per assembly by the unit
tests, by the E2E suite and by either, and the files with the most lines
no test runs. Coverage-Summary.ps1 now combines several reports, file by
file and line by line, with an optional named group per column. It only
reports: no minimum fails the build.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dkgs2000
dkgs2000 merged commit 6717bab into main Nov 26, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant