Skip to content

test: bring the test assembly to 100% line coverage - #373

Merged
Chris-Wolfgang merged 1 commit into
mainfrom
test/test-assembly-full-coverage
Sep 26, 2026
Merged

Chris-Wolfgang merged 1 commit into
mainfrom
test/test-assembly-full-coverage

Conversation

@Chris-Wolfgang

Copy link
Copy Markdown
Owner

Summary

Steps 2 and 3 of #310. The test assembly was already instrumented (IncludeTestAssembly came in with #343) and measured 97.7%. Every gap was a line that cannot execute while the test passes. Each one is fixed without weakening the test.

Class Was Fix
DocExampleCompilationTests 90.6% if (errors.Count > 0) Assert.Fail(Format(...)) → Assert.True(errors.Count == 0, Format(...)), so the message builder runs on a pass. The missing-XML-doc yield break guard is removed, so XDocument.Load throws FileNotFoundException naming the path instead of silently producing zero rows.
ReadmeExampleCompilationTests 91.2% Same assertion change. LocateReadme is a single while loop and returns a path that doesn't exist when nothing is found, so ReadAllText fails loudly. The old version returned a bare "README.md" and yielded nothing.
PropertyTests 97.7% The whitespace-message skip was a workaround for #273, which is closed. The property now asserts the type-name fallback instead of returning true, so it tests more than before.
RunAsyncFuncTests 96.1% The mid-flight cancellation probe had an unreachable return 42; after Task.Delay(Infinite). It now returns a TaskCompletionSource that the token cancels, and still asserts TaskCanceledException. The two already-canceled tests add a positive control: they invoke the probe afterwards and assert it flips, which proves the Assert.False(wasInvoked) isn't vacuous.

Heads-up, test-code changes: these edit existing tests, so please review the table above.

Verification

  • dotnet build -c Release -p:TreatWarningsAsErrors=true, test project, all 10 TFMs: 0 errors.
  • dotnet test --filter "Category!=Fuzz" with --settings coverlet.runsettings: net10.0 145 passed, net48 106 passed. Merged ReportGenerator summary: Wolfgang.TryPattern 100%, Wolfgang.TryPattern.Tests.Unit 100%, no class under 100%.

Not in this PR (remaining #310 steps)

  • Step 4: the Stage 1 gate in pr.yaml still reads with a bare while read -r line and gates everything at CODECOV_MINIMUM (90%). repo-template already has the fix (IFS= plus a 100% test-assembly gate). It's a protected-file change, so it goes in a separate bypass PR.
  • Step 5: release.yaml parity.

Refs #310

🤖 Generated with Claude Code

The test assembly measured 97.7%; every gap was a line that cannot run
while the test passes:

- Doc/README compile tests: the Assert.Fail branch only ran on a broken
  snippet. Assert.True(errors.Count == 0, message) runs the message
  builder on every pass. The missing-file `yield break` guards now let
  Load/ReadAllText throw FileNotFoundException naming the path, instead
  of silently producing zero theory rows.
- PropertyTests: the whitespace-message skip was a workaround for #273,
  which is fixed. The property now asserts the type-name fallback.
- RunAsyncFuncTests: the mid-flight cancellation probe no longer has an
  unreachable `return 42;` after an infinite delay (TaskCompletionSource
  canceled by the token). The already-canceled tests add a positive
  control that invokes the probe, proving the not-invoked assertion is
  not vacuous.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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