Repository navigation
Build xUnit and NUnit test containers through ModuleTestComposition - #142
Merged
Merged
Conversation
ModuleTestCase and ModuleTestCommand now call ModuleTestComposition.BuildAsync and dispose the returned ModuleTestContainer. Their copies of the build steps are removed. Each runner keeps its TestCaseInfo registration and the list of modules from [ModuleTest] and the module attributes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
What changed
This is step 2 of "Changes, in the order they land" in
docs/design/verificationglue.md.ModuleTestCase(DependencyModules.xUnit, and DependencyModules.xUnit4, which compiles the same sources) now builds each container with one call toModuleTestComposition.BuildAsync. It keeps the returnedModuleTestContainerobjects and disposes them inDisposeContainerswhenRunreturns. The following members are deleted:SetupServiceCollection,StartAsync,BuildServiceProvider,SetupServiceSetupAttributes,SeedEnvironment,SetupModules,DisposeProvidersand theStartupValuesrecord.ModuleTestCommand(DependencyModules.NUnit) does the same withGetAwaiter().GetResult(), and disposes the container in itsfinally. The following members are deleted:Start,BuildServiceProvider,SetupServiceSetupAttributes,SeedEnvironment,SetupModulesandDisposeProvider.Each runner keeps three things of its own:
TestCaseInforegistration, made before the call.CollectModulesmethod that returns the[ModuleTest]modules first and then theIDependencyModuleProviderattributes, widest scope first. This is the order the oldSetupModulesbuilt before it reversed the list, so the load order does not change.ModuleTestContainer.ResolveArgumentsAsyncandServices.The runners pass no overrides,
currentTest: nullandparent: null. So noICurrentTestProvideris registered, andCurrentTest.Provideris installed as before.Public API: none of the xUnit, xUnit4 or NUnit packages changes its public surface. Every removed member was private. The snapshots in
tests/DependencyModules.Specspass without changes on both majors.Three small differences in disposal come from
ModuleTestContainer.DisposeAsync. No existing test depends on any of them:BuildAsyncdisposes the container before the exception reaches the runner. Before, xUnit disposed it later, at the end ofRun.No test failed, so I did not have to fix anything in the runners or in the entry point.
Why
docs/design/verificationglue.mdPart 3, "What moves". Every runner, VerificationGlue included, should build a test's container through the same entry point. The xUnit and NUnit copies of the build order go away.How it was tested
No existing test was edited.
scripts/coverage.sh 85, on xunit.v3 3: DependencyModules.Tests 896/896, SutProject.Tests 174/174, SutProject.NUnitTests 46/46 and WebApiApp.Tests 2/2, each on net8.0 and net10.0. DependencyModules.Specs 326/326. Line coverage is 92.9%, which meets the threshold of 85%.scripts/test-xunit.sh 4: DependencyModules.Tests 897/897, SutProject.Tests 174/174 and WebApiApp.Tests 2/2, each on net8.0 and net10.0. DependencyModules.Specs withXunitMajor=4326/326.dotnet csharpier check .passes.I did not run
scripts/verify-packages.sh.🤖 Generated with Claude Code
Opened by Agent Driver for step
stp-vgdm-runnersof Tasktsk-verificationglue.