-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
chore: Migrate scope-based tests to declarative executor pattern #4271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Removed WpfAppBuilderScope, MauiTestFixture, and DispatcherSchedulerScope - Migrated 34 test files to use declarative executor pattern - Created MauiTestExecutor for MAUI test isolation - Created SuspensionHostTestExecutor for static state management - Fixed RoutingState constructor to use ImmediateScheduler.Instance in all tests - Fixed NavigationPushPopTest bug comparing subscription instead of view model - Fixed RoutingStateThrows test to properly handle ReactiveCommand exceptions - All 6,135 tests passing (intermittent net10.0 test runner infrastructure issue)
…cData - Simplified SchedulerIsUsedForAllCommands to check NavigationStack directly instead of using ToObservableChangeSet bindings - Removed all DynamicData usage from RoutingStateTests.cs to eliminate scheduling race conditions - Replaced ToObservableChangeSet().Bind() with simple List<> subscriptions in CurrentViewModel tests - Removed unused DynamicData bindings from RoutingStateThrows test - All 6,155 tests now passing reliably across all frameworks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR refactors the test infrastructure by migrating from manual scope-based test patterns (using [Before(Test)]/[After(Test)] hooks) to a declarative executor pattern using [TestExecutor<T>] attributes. This modernization eliminates 1,002 lines of boilerplate setup/teardown code while centralizing platform-specific configuration in reusable executors.
Changes:
- Created
MauiTestExecutorandSuspensionHostTestExecutorfor centralized test isolation with proper state management - Deleted 4 obsolete scope/fixture classes:
WpfAppBuilderScope,DispatcherSchedulerScope, and 2MauiTestFixturefiles - Migrated 34 test files to executor pattern (21 WPF, 12 MAUI, 1 suspension test) with removal of 1,000+ lines of boilerplate
- Fixed critical bugs in
RoutingStateTests.cs: removed DynamicData race conditions, fixed navigation test assertions, proper ReactiveCommand exception handling, and added explicit schedulers to allRoutingStateconstructors - Updated project files with proper references and using directives for MAUI test projects
Reviewed changes
Copilot reviewed 43 out of 43 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
MauiTestExecutor.cs |
New executor providing MAUI dispatcher isolation and cleanup |
SuspensionHostTestExecutor.cs |
New executor managing static state in SuspensionHostExtensions |
WpfAppBuilderScope.cs |
Deleted - functionality moved to WpfTestExecutor |
DispatcherSchedulerScope.cs |
Deleted - functionality integrated into WpfTestExecutor |
MauiTestFixture.cs (2 files) |
Deleted - replaced with MauiTestExecutor |
RoutingStateTests.cs |
Fixed race conditions, navigation bugs, and added explicit schedulers |
RoutedViewHostTests.cs |
Removed [Skip] attributes, added inline WpfWithViewAndRoutingExecutor |
XamlViewCommandTests.cs and 19 other WPF test files |
Migrated to WpfTestExecutor pattern, removed boilerplate |
| 11 MAUI test files | Migrated to MauiTestExecutor pattern, removed boilerplate |
SuspensionHostExtensionsTests.cs |
Migrated to SuspensionHostTestExecutor pattern |
WinFormsViewModelViewHostTests.cs |
Added TearDown to reset static state |
ReactiveUI.Maui.Tests.csproj |
Added TUnit using directives |
ReactiveUI.Builder.Maui.Tests.csproj |
Added project reference to ReactiveUI.Maui.Tests and using directives |
- Fixed RoutedViewHostTests.cs (WPF) missing scheduler parameter - Fixed WinFormsRoutedViewHostTests.cs (3 instances) missing scheduler parameter - Fixed AdvancedAOTTests.cs missing scheduler parameter - Ensures all test RoutingState instances execute synchronously preventing async hangs - All 6,155 tests passing
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4271 +/- ##
==========================================
+ Coverage 78.23% 78.70% +0.47%
==========================================
Files 248 248
Lines 9552 9552
Branches 1459 1459
==========================================
+ Hits 7473 7518 +45
+ Misses 1839 1792 -47
- Partials 240 242 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
What kind of change does this PR introduce?
Refactoring - Test infrastructure improvement and bug fixes
What is the current behavior?
Tests used scope-based patterns with manual
Before/Afterhooks (WpfAppBuilderScope, MauiTestFixture, DispatcherSchedulerScope) requiring boilerplate setup/teardown code in each test class. Some tests had intermittent failures due to:ToObservableChangeSet().Bind()race conditions in scheduler testsImmediateScheduler.Instancein someRoutingStateconstructors causing async hangsWhat is the new behavior?
Tests use declarative executor pattern with
[TestExecutor<T>]attributes, centralizing setup logic and eliminating boilerplate:Test Infrastructure Changes:
MauiTestExecutorfor MAUI test isolation with dispatcher setupSuspensionHostTestExecutorfor managing static state in suspension testsWpfAppBuilderScope,MauiTestFixture(2 files),DispatcherSchedulerScopeBug Fixes:
SchedulerIsUsedForAllCommandsintermittent failure by removingToObservableChangeSet()race conditionsRoutingStateconstructors to useImmediateScheduler.Instancepreventing test hangsNavigationPushPopTestbug that compared subscription object instead of view modelRoutingStateThrowsto properly handle ReactiveCommand exceptions viaThrownExceptionsRoutingStateTests.csto eliminate scheduling issuesResults:
What might this PR break?
No breaking changes - purely internal test infrastructure improvements. All tests remain functionally equivalent with the same coverage.
Please check if the PR fulfills these requirements
Other information:
This refactoring improves test maintainability by:
Co-authored-by: Christian Fischerauer [email protected]