[WIP] Stabilize ReactiveUI.Tests by isolating static state and de-parallelizing affected tests #4167
+0
−0
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.
Note: Build environment requires Windows with .NET 8/9/10 SDKs. Current Linux environment cannot build/test but can prepare code changes.
Original prompt
This section details on the original issue you should resolve
<issue_title>Stabilize ReactiveUI.Tests by isolating static state and de-parallelizing affected tests</issue_title>
<issue_description>Goal: Make tests deterministic. Audit tests for usage of static/global state and ensure each such test:
This work is blocked unless the build & test environment is set up exactly as specified below. Follow the pre-flight steps first.
🔒 Pre-flight: Build Environment Requirements (must be completed before any code changes)
Cloning the Repository
CRITICAL: Perform a full, recursive clone. A shallow clone (
--depth 1
) will fail because the build reads git version info.Required Tools
CRITICAL: Install all three SDKs via the official script:
(Tip: ensure
./.dotnet
is on PATH for this shell session, or call it explicitly via./.dotnet/dotnet
.)Solution Files
src/ReactiveUI.sln
integrationtests/
(not required for this task)🛠️ Build & Test Commands (Windows PowerShell or CMD, repository root)
CRITICAL:
dotnet workload restore
must be run from/src
before building.Note: Building on Linux/macOS will fail due to
net*-windows
targets and AOT tests. Use Windows.🧭 Context & Example Failure
We’re seeing intermittent failures tied to static/global state. Example:
This indicates tests mutate or rely on global/static state (e.g.,
RxApp
, service locator, schedulers, message bus, etc.) without restoring it. Running in parallel amplifies the flakiness.✅ What to do
1) Discover tests that touch static/global state
Search for usages of well-known static entry points or singletons anywhere under
src/ReactiveUI.Tests
:RxApp.
,MessageBus.
,SuspensionHost.
,Interaction.
,ModeDetector.
,LogHost.
Locator.
,Locator.Current
,Locator.CurrentMutable
,DependencyResolver
,Splat.Locator
static
members that mutate shared state (caches, registries, global flags, default schedulers, etc.)Suggested queries (run at repo root):
Output: Build a checklist of test files and specific tests that read or write static/global state.
2) Make affected tests non-parallelizable (targeted)
For each test fixture or test that touches static/global state, explicitly disable parallelization with NUnit:
At the fixture level (preferred when multiple tests in a class touch static state):
Or at the individual test level if only one or two tests are affected:
Do not disable parallelization assembly-wide. Keep the scope as tight as possible.
3) Introduce helper scopes to snapshot & restore static state
Create small, focused disposable scopes for each area of static state. These should snapshot on construction, and restore on
Dispose()
. Use them inSetUp
/TearDown
or inusing
blocks inside tests.💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.