| name | testing-wpf |
| description | Create and maintain WPF UI tests and ViewModel tests for the .NET 8 widget host app. Use when setting up UI automation, testing MVVM logic, or building a test harness for widgets and the shell. |
Testing Wpf
Overview
Cover UI behavior and ViewModel logic without coupling tests to WPF internals.
Core areas
- ViewModel unit tests
- UI automation tests
- Test harness for widget windows
Workflow
- Write ViewModel tests for commands, state, and validation.
- Use UI automation sparingly for critical flows.
- Keep UI tests stable by controlling test data and timings.
- Build a test harness that can host widgets and shell views.
Guidance
- Prefer ViewModel tests over UI automation where possible.
- Avoid fragile selector strategies in UI tests.
- Keep test runs isolated from user desktop state.
References
references/ui-testing.mdfor UI automation strategy.references/viewmodel-tests.mdfor MVVM test patterns.references/test-harness.mdfor widget test host setup.