Repository navigation
chore(tests): move the test projects to xUnit v3 - #1467
Merged
Merged
Conversation
All 16 test projects move from xunit 2.9.3 to xunit.v3.mtp-off 4.0.2 and become executables. mtp-off keeps VSTest, so dotnet test, the coverlet collector and coverage.runsettings work unchanged, and scaffolded projects need no global.json test-runner setting. IAsyncLifetime returns ValueTask in v3; both WebApplicationFactory fixtures now override DisposeAsync instead of hiding it. xUnit1051 is off for src/Tests: its code fix makes NSubstitute setups and Received() checks expect the test's cancellation token. v3's different test order exposed four hidden dependencies, fixed in the harness: - Derived WithWebHostBuilder hosts left JobStorage.Current and the static Audit publisher pointing at their disposed storage and channel. PrimaryHostStaticsRestorer repoints both at the shared host on stop. - Provisioning-failure tests left unreachable-database tenants behind; they now remove them via FshWebApplicationFactory.RemoveTenantsAsync. - The audit tenant-isolation poll now excludes EntityChange seed rows, which can fill more than the first page. - The within-limit rate-limit test uses its own client IP instead of the partition the 429 test exhausts.
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.
Closes #1457.
All 16 test projects move from
xunit2.9.3 to xUnit v3 (xunit.v3.mtp-off4.0.2).Why
mtp-off. The defaultxunit.v3package turns on Microsoft.Testing.Platform, and then the .NET 10 SDK refuses VSTest-styledotnet testunlessglobal.jsonopts into the new runner. The template doesn't shipglobal.json, so every scaffolded project would losedotnet test.mtp-offkeeps VSTest:dotnet test,--filter, the coverlet collector andcoverage.runsettingsall work as before, and CI's test steps don't change. Moving to MTP can be a separate change.The migration itself:
<OutputType>Exe</OutputType>).IAsyncLifetimereturnsValueTaskin v3.FshWebApplicationFactoryandMiddlewareWebApplicationFactorynow overrideWebApplicationFactory.DisposeAsync()instead of hiding it withnew, so there's a single disposal path. The five test classes with their own lifetimes are updated too.xUnit1051is off forsrc/Tests(src/.editorconfig, with the reason). I tried its code fix first. It also addsTestContext.Current.CancellationTokento NSubstitute setups andReceived()checks, which changes what the mock matches, because handlers under test getCancellationToken.None. In the integration tests it changes about 1,900 lines and adds that token to almost every one. The suite has no test timeouts for the token to serve.Hidden test-order dependencies. v3 orders tests differently, and that exposed four places where tests relied on running in a particular order. The first full run had 189 failures. All four fixes are in the test harness; no production code changes.
WithWebHostBuilderhosts (webhook tests) replace two process-wide statics, Hangfire'sJobStorage.Currentand the staticAuditpublisher, and leave them pointing at their own storage and channel after disposal. Later enqueues threwObjectDisposedException(most of the 189), and request audits went into a channel nobody reads. The newPrimaryHostStaticsRestorerpoints both back at the shared host whenever a host stops.TenantProvisioningFailureTestsandRetryTenantProvisioningTestsleft tenants with an unreachable database in the store, so the legacy public-key migration job (which walks every tenant) failed inStorageVisibilityRootTests. They now remove their tenants through a newFshWebApplicationFactory.RemoveTenantsAsync.EntityChangeseed rows, depending on what earlier tests created. It now excludesEntityChange.Tested:
dotnet build src/FSH.Starter.slnx: 0 warnings, 0 errors.dotnet test src/FSH.Starter.slnx: 2,225/2,225 passing. Every project's count matches main's last Backend CI run: Integration 805, Middleware 7, Framework 373, Identity 352, and so on.--collect "XPlat Code Coverage" --settings coverage.runsettingsstill producescoverage.cobertura.xml.Docs: fullstackhero/docs PR to follow (testing pages and changelog).