What problem does it solve?
Provides practical guidance and best practices to make .NET MAUI ViewModels and platform-dependent services reliably unit-testable, avoiding fragile UI-bound tests and platform-specific build pitfalls.
Core Features & Use Cases
- ViewModel-first testing: patterns to test ViewModel state and commands rather than UI bindings for fast, deterministic tests.
- Mocking MAUI services: recommended mock strategies for ISecureStorage, IPreferences, IConnectivity, IGeolocation, IFilePicker, IMediaPicker, IDispatcher and abstracting Shell/Application behind interfaces.
- Test project setup & build gotchas: guidance on creating class library test projects targeting plain net9.0/net10.0, conditional OutputType for app projects, and CI-friendly dotnet test workflows.
- Code coverage & on-device runners: instructions for using coverlet and xunit.runner.devices when real platform APIs are required.
Quick Start
Create a class library test project targeting net9.0/net10.0, add xUnit, Microsoft.NET.Test.Sdk, Moq and coverlet, reference your MAUI app with a conditional OutputType for the test TFM, and run dotnet test to validate ViewModel tests.