Reset test-double state after each test through a test-only IResettableTestState contract, so the test harness clears its captures and stubs on its own, and bound every resource reset by the step timeout - #435
Open
Vulthil wants to merge 1 commit into
Conversation
…leTestState contract, so the test harness clears its captures and stubs on its own, and bound every resource reset by the step timeout
This branch has not been deployed
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.
Summary
Test-double state in a test host is now reset after each test, through a test-only contract, and every resource reset has the same time limit as the other reset steps.
Before, the messaging test harness kept its captured messages and its
Handle/Respondstubs for the whole life of the host. A test class that shared one host saw the earlier tests' messages, and a stub from one test kept answering in the next tests. The testing article told users to callClear()fromInitialize(), but resolving the harness there builds the host before the test can register its doubles, soGetMock/Usethen throw.Clear()also kept the stubs. Separately, the article said that every reset step has a 30-second bound, but only the service stop and restart steps had one: a resource reset that hung blocked the teardown forever.IResettableTestState(new, inVulthil.Extensions.Testing, the framework-agnostic test package): state that a test double keeps in a test host's services, withValueTask ResetAsync(CancellationToken). It lives in a test package, so no runtime package gets a test-only seam.UseTestHarness()/ReplaceTransportWithTestHarness()also register the harness as anIResettableTestState. Its reset clears the captured messages and removes the stubs.Clear()keeps its meaning (captured messages only).ITestHarnessis unchanged.Vulthil.xUnit: after each test,BaseIntegrationTestCaseresets everyIResettableTestStateof every live host of the class, in the same pause as the database reset. Every live host, not only the newest, because the next test can run on the class's shared host after a test that ran on a per-test host. An instance that two hosts share is reset once.testing.mddrops theInitialize()/Clear()advice, documents the automatic reset and when startup messages are visible, and gets a "Resetting your own test doubles" section; the package pages, the harness README and the XML docs are updated.Public API: one added interface (
Vulthil.Extensions.Testing.IResettableTestState).Vulthil.xUnitandVulthil.Messaging.TestHarnessnow depend onVulthil.Extensions.Testing. No break.Verification
dotnet build Vulthil.SharedKernel.slnx: 0 warnings, 0 errors.TestHarnessTests: the harness is the host's only resettable test state; a reset clears the captured messages; a reset removes theHandlestubs; a reset removes theRespondstubs so the request consumer answers again;Clear()keeps the stubs.TestHostResetTests: test states reset while the services are stopped; a failing test-state reset is reported and the services still restart; a resource reset that never completes is abandoned at the step bound and the services restart; a test-state reset that honours its token is cancelled at the step bound.TestHostScopeTests: the test states of every live host are reset; a state that two live hosts share is reset once; the states of a stopped host are not reset.Vulthil.IntegrationTests(TestHarnessResetIntegrationTests, Docker): the teardown after a test clears the shared host's harness captures and stubs.Vulthil.IntegrationTests(Docker): 71/71 on net10.0 and net9.0.MessagingIntegrationTests: 13/13 on net10.0.dotnet packpackage validation against 1.2.0 passes forVulthil.Extensions.Testing,Vulthil.Messaging.TestHarnessandVulthil.xUnit.docfxdocs build: 0 warnings, 0 errors.Clear()also removes the stubs: 1 harness test fails;Backport to v1.0: no