Repository navigation
[DRK-2616] Move DKNet test code from xunit 2 to xunit.v3 - #548
Conversation
Pins the four automatable DRK-2622 scenarios: 27 test projects and the src package pin on xunit.v3 only, the snippet lab on xunit.v3 only, the dknet-testing skill install row, and its ValueTask lifetime shape with all 17 csharp examples kept. Red on purpose until the stage 2 Builds land. Co-Authored-By: Claude Opus 5.5 <[email protected]> Co-authored-by: multica-agent <[email protected]>
…RK-2626] - Lab pins xunit.v3.extensibility.core 4.0.2 in place of xunit 2.9.3 (Library stays a Library). - dknet-testing install row names xunit.v3. - IAsyncLifetime examples use the v3 ValueTask InitializeAsync/DisposeAsync shape. Co-Authored-By: Claude Opus 5.5 <[email protected]> Co-authored-by: multica-agent <[email protected]>
The local Aspire.Hosting.ServiceBus.dll is built against Aspire.Hosting 13.6.5 since e65142c; the lab's 13.5.3 pin made dknet-slimbus-cqrs fail with CS1705. Co-Authored-By: Claude Opus 5.5 <[email protected]> Co-authored-by: multica-agent <[email protected]>
- Pin xunit.v3.mtp-off 4.0.2 in place of xunit 2.9.3; runner stays 4.0.0. - IAsyncLifetime InitializeAsync/DisposeAsync return ValueTask; drop Xunit.Abstractions usings (ITestOutputHelper lives in Xunit in v3). - WebApplicationFactory fixtures override DisposeAsync instead of hiding it. - Assembly-level serial runs use Parallelization(Mode = ParallelMode.None): CollectionBehavior.DisableTestParallelization is an obsolete error in v3. - Suppress xUnit1051 in the two SlimBus.Generators test projects. Co-Authored-By: Claude Opus 5.5 <[email protected]> Co-authored-by: multica-agent <[email protected]>
…s [DRK-2625] These tests opened the per-class fixture database without creating it and passed only because xunit 2 happened to run a creating test first. xunit.v3 orders test cases differently, and Remote Unit Tests run 45756321744 failed GetDbConnection_WithClosedConnection_ShouldOpenConnection with 3D000 "database does not exist". Each test now calls EnsureCreatedAsync in its Arrange, so it passes alone and in any order. Co-Authored-By: Claude Opus 5.5 <[email protected]> Co-authored-by: multica-agent <[email protected]>
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
📊 Code Coverage Report |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #548 +/- ##
==========================================
+ Coverage 93.25% 93.32% +0.06%
==========================================
Files 219 219
Lines 7191 7191
Branches 1220 1220
==========================================
+ Hits 6706 6711 +5
+ Misses 259 254 -5
Partials 226 226
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Automated review gate — PR #548
|
| Category | Weight | Score | Notes |
|---|---|---|---|
| Correctness & logic | 25% | 10 | Dispose paths, serial attributes and fixture scopes all verified (below) |
| Security | 20% | 10 | Test code and markdown only; no new package source |
| Testing & coverage | 20% | 9.5 | 1 nit; the MsSqlStore flake is declared LEFT OPEN, so it is not deducted |
| Architecture & design | 15% | 10 | §3b holds: dependencies change only for the test projects and the lab |
| Spec conformance | 10% | 10 | All §5 @new scenarios are green; @existing scenarios are proven by CI and the Build's evidence |
| Style & conventions | 5% | 10 | Analyzers clean; the xUnit1051 NoWarn has a one-line reason (R1) |
| AI-slop gate | 5% | 10 | — |
Weighted average 9.9. No cap fired.
Verified evidence
- No test lost or skipped (CI logs). Remote Unit Tests on base
0f617e6(run 45753937283): 27 assemblies, 3022 total, 3022 passed, 0 skipped. On headf86df94(run 45759598619): 3026 total, 3026 passed, 0 skipped.build-test-coverageon head (run 45759820078): 3026/3026, 0 skipped, coverage 95% ≥ 80%. Every per-assembly total is the same exceptFw.Extensions.Tests, which goes from 165 to 169 (the 4 guards). The diff adds noSkip, and noShould*/Assert.*line changes. - Acceptance-test contract.
git diff 81f5ac2..HEAD -- src/Core/Fw.Extensions.Tests/RepoGuards/XunitV3GuardTests.csis empty.at_sha81f5ac2is the first commit after base, so it comes before every implementation commit. G1–G4 are green in CI. - Fixture lifetimes. The only types that implement both
IAsyncLifetimeandIDisposableareGadgetTestHost(TestHost.cs:42),GadgetAuthTestHost(TestHost.cs:181),GadgetExclusionTestHost.cs:28andGroupScopeCrudTestHost(GroupScopeCrudTests.cs:49). EachDispose()only disposes_connection, and eachDisposeAsync()disposes it too (TestHost.cs:132,TestHost.cs:273,GadgetExclusionTestHost.cs:95,GroupScopeCrudTests.cs:115). So no cleanup lives only inDispose(). The other files on the brief's list (AuditLogs, Events, Hooks, NpgsqlStore) have no type that disposes both ways. TheirDispose()methods belong to nested logger providers. - WAF
new→override DisposeAsync. I checked this atMsSqlStore.Tests/Fixtures/ApiFixture.cs:87-95,NpgsqlStore.Tests/Fixtures/ApiFixture.cs:72-80andAspCore.Idempotency.Tests/Fixtures/ApiFixture*.cs. Each override stops its container and then awaitsbase.DisposeAsync()once. xunit.v3 disposes a fixture once, throughDisposeAsyncalone, so the host and the container are each torn down once. Container stop counts are the same before and after (DRK-2625 evidence). - Serial groups.
[assembly: Xunit.v3.Parallelization(Mode = Xunit.Sdk.ParallelMode.None)]replaces the 3 assembly-levelCollectionBehavior(DisableTestParallelization = true)attributes (an error-level obsolete in v3). The xunit.v3 4.0.2 XML docs confirmParallelMode.Nonedisables all parallelism in the assembly. The 2 group-levelCollectionDefinition(..., DisableParallelization = true)attributes and the 3ICollectionFixturedefinitions are unchanged. - Relational.Helpers arrange (
f86df94). The 5 addedEnsureCreatedAsynccalls (DbContextHelpersAdvancedTests.cs:104,131,212,DbContextHelpersEdgeCaseTests.cs:22,105) make the database state explicit.TableExistsAsync(DbContextHelpers.cs:102-122) does not create the database itself. So these tests passed on base only when an earlier test had already created it. Every assertion is unchanged, and every subject call (GetDbConnection,TableExistsAsync) still determines its test's result. - Skill. 17 fences are kept (6 + 11), with 0
no-compilemarkers. The install row isdotnet add package xunit.v3. The Build quotes the lab output: all 13 skillsBuild succeeded. - Loosened-check scan. One suppression,
xUnit1051, in the 2 SlimBus generator test csproj, with a reason comment on the line above. No analyzer, coverage or CI config file is in the diff.
Findings
praise
src/Core/Fw.Extensions.Tests/RepoGuards/XunitV3GuardTests.cs:80-86,108-113— the guards parse withXDocumentand match exactIncludevalues. A missing repo root fails loudly, so the guards can never pass vacuously. The fence count of 17 stops anyone from deleting an example to turn G4 green.src/AspNet/AspCore.Idempotency.MsSqlStore.Tests/Fixtures/ApiFixture.cs:87-95— the switch fromnewtooverridewithbase.DisposeAsync()is the right v3 shape: teardown runs once through one path.- The Build's before/after evidence (per-project counts, container start/stop counts per image, coverage module list) made this review checkable. My independent CI-log check matched it exactly.
nit
-
src/EfCore/EfCore.Relational.Helpers.Tests/DbContextHelpersAdvancedTests.cs:202— the test nameTableExistsAsync_WithNonExistingTable_ShouldReturnTruenow contradicts its explicit arrange (EnsureCreatedAsyncat:212) and its assertion. The name is older than this PR, and the brief forbade renames, so this goes in Merged with. -
src/AspNet/AspCore.Idempotency.MsSqlStore.Tests/Integration/IdempotencyIntegrationTests.cs:75-78(declared LEFT OPEN by the Build, so not deducted). This explains the intermittentsuccessCountof 2–3:- The fixture uses
ConflictHandling = CachedResult(Fixtures/ApiFixture.cs:78). - A duplicate that arrives after the winner's
MarkKeyAsProcessedAsyncgets the cached 201 replayed (DKNet.AspCore.Idempotency/Filtering/IdempotencyEndpointFilter.cs:212-215). The sequential test in the same file already asserts exactly that (:246,:269). - The concurrency test counts every 201, so
successCount= 1 + the number of the 5 requests that did not overlap the winner. - The Npgsql sibling already fixed the same test. It documents this mechanism and asserts that every 201 carries the same Id (
AspCore.Idempotency.NpgsqlStore.Tests/Integration/IdempotencyIntegrationTests.cs:72-80). The MsSql copy was never brought into line.
The flaw is in the test assertion, and it predates this PR. It is not a store defect: the handler runs once. The runner change from v2 to v3 may change how often the 5 requests serialize, and so how often the flaw fires. The local sample (2/8 on head vs 0/4 on base) cannot separate the two trees. The test body, the fixture configuration, the filter and the store are all unchanged, and both CI runs on
f86df94pass. The comment at:60-62("the other four are turned away as conflicts") makes the same wrong assumption.Suggested fix, for whenever someone next touches this file: mirror the Npgsql assertion.
- The fixture uses
Out-of-scope observations
None clears the worth-fixing bar.
Gate notes
- Release review: none. There is no auth or crypto code, no workflow change, no package-source or lockfile-source change, no gate-authored commit, and no owner-review request.
- CI: green.
build-test-coverage (10.x.x),test,codecov/patch,codecov/project, Socket ×2 andsecurity/snykall pass. - Vote: skipped, because the PR is self-authored (gh identity = PR author). This report comment is the record.
Summary
This PR moves all DKNet test code from xunit 2.9.3 to xunit.v3: the 27 test projects, the snippet lab and the
dknet-testingskill examples. Maintainers and plugin users then use the supported xunit line, the same one DKNet.Templates already uses. Spec: DRK-2616, revision 18.Evidence
XunitV3GuardTestsfailed at81f5ac2, because xunit 2 was pinned insrc/, in the lab and in the skill's install row and lifetime examples.f86df94. The CI command found 3026 tests: 3026 passed, 0 failed, 0 skipped. The baseline at0f617e6found 3022, so the difference is the 4 new guards. The coverage threshold check passed (95% ≥ 80%). Mutation is n/a, because no production class changed.Build succeeded., and the 17dknet-testingfences are all kept.Merge danger
Door: two-way. Only test code, skill text and lab pins change; reverting the merge commit restores xunit 2.
Blast radius: repo. No NuGet package changes.
@drunkcoding/dknet-skillsgets the newdknet-testingtext at the next release.Details
CollectionBehavior(DisableTestParallelization = true)gives error CS0619. The 3 projects that used it now use[assembly: Xunit.v3.Parallelization(Mode = ParallelMode.None)], and the runner reportsparallel mode = none.WebApplicationFactoryfixtures,new Task DisposeAsyncbecameoverride ValueTask DisposeAsync. In v3,IAsyncLifetimeextendsIAsyncDisposable, so these methods now override the base method instead of hiding it.EfCore.Relational.Helperstests now create their fixture database in Arrange. They had passed only because of xunit 2's test order, and each fails when run alone on0f617e6.xUnit1051is suppressed in the 2 SlimBus generator test csproj files, each with a comment.