Repository navigation
test: collect coverage from DocExamples and Fuzz and bring both to 100% - #314
Merged
Merged
Conversation
The DocExamples and Fuzz test projects had no coverlet.collector, so Stage 1
ran their tests but recorded no coverage row for either assembly. Add the
collector at the version the Unit project uses (10.0.1) and cover the lines
that a passing run never reached:
- Fuzz: the null-receiver properties used try { call; return false; } catch,
so `return false` could never run on a pass. Assert.Throws now fails the
property when nothing is thrown, and the property also checks ParamName.
- DocExamples: the failure-message lambda ran only on a failing example
(join the diagnostics directly); FindSrcDirectory takes its start
directory so its not-found throw is tested; the library reference is
added before the TPA loop instead of behind a branch the TPA list always
short-circuited; DocExample's parameterless ctor and Deserialize are
exercised through xunit's SerializationHelper round-trip.
- Unit: SuppressTfmSupportBuildWarnings for the System.IO.Hashing
net5.0-net7.0 warning from Microsoft.SourceLink.GitHub, so Release builds
are warning-free.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The changes correctly close the stated coverage gaps without altering production behavior.
Review effort: Balanced
Findings: None
What changed in this PR
Ensures all test assemblies participate in the repository’s 100% coverage gate.
Changes:
- Adds Coverlet collection to DocExamples and Fuzz tests.
- Covers previously unreachable infrastructure paths.
- Suppresses known legacy-TFM dependency warnings.
| File | Description |
|---|---|
tests/Wolfgang.Extensions.IComparable.Tests.Unit/Wolfgang.Extensions.IComparable.Tests.Unit.csproj |
Suppresses known TFM support warnings. |
tests/Wolfgang.Extensions.IComparable.Tests.Fuzz/Wolfgang.Extensions.IComparable.Tests.Fuzz.csproj |
Enables coverage collection. |
tests/Wolfgang.Extensions.IComparable.Tests.Fuzz/IComparableExtensionsProperties.cs |
Strengthens null-receiver properties. |
tests/Wolfgang.Extensions.IComparable.Tests.DocExamples/Wolfgang.Extensions.IComparable.Tests.DocExamples.csproj |
Enables coverage collection. |
tests/Wolfgang.Extensions.IComparable.Tests.DocExamples/DocExampleRotTests.cs |
Makes harness paths testable and reliably references the library. |
tests/Wolfgang.Extensions.IComparable.Tests.DocExamples/DocExampleInfrastructureTests.cs |
Tests source lookup failure and serialization. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Makes every test assembly report coverage at 100%, so Stage 1 on the sync PR stops failing with "tests ran but no coverage was recorded".
Unblocks #313; part of #307.
Per assembly
Tests.DocExamplescoverlet.collectorreference (#313's Stage 1:Coverage: none collected)coverlet.collector10.0.1 (same asTests.Unit), then cover the gaps belowTests.Fuzzcoverlet.collectorreference (same log)coverlet.collector10.0.1, then cover the gaps belowTests.UnitWolfgang.Extensions.IComparable(src)Once collected, DocExamples measured 90.1% and Fuzz 96%. The uncovered lines and what changed:
IComparableExtensionsProperties.cs): the two null-receiver properties usedtry { call; return false; } catch (ArgumentNullException) { return true; }.return falsecannot run on a passing run. They now useAssert.Throws<ArgumentNullException>(which fails the property when nothing is thrown) and return whetherParamNameisvalue, which is a slightly stronger check than before.DocExampleRotTests.cs):string.Join(NewLine, errors)); the message still names the example's file:line and each diagnostic.FindSrcDirectorynow takes its start directory (production call passesAppContext.BaseDirectory, as before), so the "src not found" throw is tested.if (... && seen.Add(lib)), which was always false because the test host's TPA list already contains the library. It is now added first, unconditionally, and the TPA loop skips it as already seen.DocExample's parameterless constructor andDeserialize(used by xunit when discovery and execution are split) are exercised by a serialization round-trip through xunit's realSerializationHelper.SuppressTfmSupportBuildWarningsadded.dotnet nuget whyshowsSystem.IO.Hashing10.0.12 comes in throughMicrosoft.SourceLink.GitHub10.0.401, and its buildTransitive targets warn on net5.0/6.0/7.0. This was 3 warnings in a Release build before the change and 0 after.Exclusions removed
None. There were no
[ExcludeFromCodeCoverage]attributes undertests/, and none were added.Test changes (for review)
tests/Wolfgang.Extensions.IComparable.Tests.DocExamples/DocExampleInfrastructureTests.cswith 2 tests:FindSrcDirectory_when_no_ancestor_contains_the_src_project_throws_DirectoryNotFoundExceptionandDocExample_when_round_tripped_through_xunit_serialization_preserves_every_property.DocExampleRotTests.cs(failure-message lambda,FindSrcDirectory(string), library-reference ordering).IComparableExtensionsProperties.cs(two null-receiver properties, as described above).coverlet.collector; Unit addsSuppressTfmSupportBuildWarnings.Verified locally (Windows, this branch)
dotnet build IComparable-Extensions.slnx -c Release: 0 warnings, 0 errors.dotnet teston the slnx: all green. Unit had 117 tests on each of net5.0 through net10.0 and 111 on net462/472/48/481. Fuzz had 12 and DocExamples 5, both on net10.0.--collect:"XPlat Code Coverage" --settings coverlet.runsettings, thendotnet reportgenerator.Summary.txthas a row for every test assembly that ran (DocExamples, Fuzz, Unit; AotSmoke is not a test project and is skipped there too). Every row is at 100%, and src is at 100%.No changelog fragment: nothing under
src/changed.Round 2 (2026-10-04)
Re-measured with #313's Round 2 config (repo-template#701 Stage 2 integration skip, and #702
coverlet.runsettingswith comma-separated lists and<Exclude>limited to[*]AutoGeneratedProgram). Local run: this PR's head a1aa6ef, Release, net8.0 + net10.0. Every assembly stays at 100%: src, Tests.DocExamples, Tests.Fuzz and Tests.Unit, under both the old and the new runsettings. No further test changes were needed.Merge order: this PR first, then #313.
🤖 Generated with Claude Code