Skip to content

Fix test-fixture reset routing, outbox restart overlap, and test-harness consumption/disposal bugs#338

Merged
Vulthil merged 2 commits into
mainfrom
fix/testing-stack-fixture-reset
Jul 20, 2026
Merged

Fix test-fixture reset routing, outbox restart overlap, and test-harness consumption/disposal bugs#338
Vulthil merged 2 commits into
mainfrom
fix/testing-stack-fixture-reset

Conversation

@Vulthil

@Vulthil Vulthil commented Jul 20, 2026

Copy link
Copy Markdown
Owner

Summary

  • BaseIntegrationTestCase's post-test reset always ran against the shared class-fixture factory, even
    when a test overrode CreateFactory() to run on a WithWebHostBuilder(...)-derived host. That silently
    built a second, unused host and paused the wrong one's background services while Respawn wiped the
    shared database. Reset now targets whichever factory the test actually ran on, and is skipped entirely
    when a test never built a host.
  • Giving the reset a real, cancellable timeout (instead of an internal-only bound) opened a window where
    OutboxBackgroundService.StartAsync could start a second relay loop before a slow-to-stop previous one
    had actually finished. StartAsync now waits for an incomplete previous execute task before starting a
    new one.
  • The in-memory test harness recorded a request as "consumed" even when the request consumer threw,
    because RecordConsumed ran before the consumer's await instead of after (already correct for one-way
    consumers).
  • BaseUnitTestCase now disposes a created Target on teardown if it's disposable.
  • Docs/XML-doc corrections: AddHttpMock's "configure up front" language contradicted the documented
    per-test reset behavior; ITestHarness's singleton-lifetime capture leak across tests sharing one host
    is now documented with a Clear()-from-Initialize() pattern.
  • Re-verified several previously reported fixture issues (container-collection mutation during parallel
    iteration, a teardown-skipping initialization guard, lazy scope/client thread-safety, a Cosmos
    readiness wait "falling through") against current code and found them already fixed - no change needed.

Verification

  • Full solution build: clean.
  • Unit suites (Vulthil.SharedKernel.Outbox.Tests, Vulthil.Messaging.TestHarness.Tests,
    Vulthil.SharedKernel.Tests): all passing, net9.0 and net10.0.
  • Full Vulthil.IntegrationTests suite against real Postgres/MySQL/Cosmos containers: all passing,
    net9.0 and net10.0 - confirms no regression to existing integration coverage.
  • Each new/extended test was confirmed to fail against the pre-fix code and pass against the fix.

Backport to v1.0: no - test-infrastructure behavior changes; ships with the next minor.


Amendment: UseReal/UseRealFor now register the real instance as a lazy factory instead of constructing it
immediately - it is built the first time it's actually resolved (directly or as a dependency), so a dependency
registered afterward but before that resolution is now visible to it (previously it would have been auto-mocked).
BaseUnitTestCase.Dispose() now also disposes every disposable instance the auto-mocker holds (Use() instances,
resolved UseReal/UseRealFor instances, auto-generated dependency mocks) via AutoMocker.AsDisposable(), in
addition to the existing Target disposal - Target is still disposed first. Only synchronous IDisposable is
covered; an IAsyncDisposable-only registration still needs a manual override. These are the two behavior changes
reviewers should look for: construction timing for UseReal/UseRealFor, and new automatic disposal of anything
the auto-mocker holds.

@Vulthil
Vulthil merged commit 52ba9db into main Jul 20, 2026
3 of 4 checks passed
@Vulthil
Vulthil deleted the fix/testing-stack-fixture-reset branch July 20, 2026 19:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant