maui-unit-testing
Installation
SKILL.md
MAUI Unit Testing
Use this skill to make MAUI app logic testable without requiring every test to start a device or simulator. Keep UI framework dependencies at the edges.
Workflow
- Identify what is being tested: ViewModel, service, navigation abstraction, storage wrapper, platform capability, or UI integration.
- For ViewModels and services, create a normal xUnit test project.
- Introduce interfaces around platform APIs such as geolocation, preferences, secure storage, media picker, file picker, and navigation.
- Use fakes or mocks for those interfaces in unit tests.
- Use device/integration tests only for behavior that requires handlers, platform permissions, native controls, or OS services.
- If a test or tooling project must reference a MAUI app project, use the
AppProjectReference support provided by
Microsoft.Maui.Build.AppProjectReferenceinstead of forcing the app project to behave like a normal class library.