maui-unit-testing

Configure xUnit test projects and mock MAUI services for ViewModel testing.

163|17|Updated Feb 12, 2026
One-click install
npx skills add https://github.com/davidortinau/maui-skills --skill maui-unit-testing
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: maui-unit-testing
Source: https://github.com/davidortinau/maui-skills/tree/main/plugins/maui-skills/skills/maui-unit-testing
Command: npx skills add https://github.com/davidortinau/maui-skills --skill maui-unit-testing

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires xunit, xunit.runner.visualstudio, Microsoft.NET.Test.Sdk, coverlet.collector, Moq, and includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill provides guidance on setting up and writing effective unit tests for .NET MAUI applications using the xUnit testing framework, ensuring code quality and maintainability.

Core Features & Use Cases

  • xUnit Test Setup: Configure test projects for .NET MAUI with necessary NuGet packages.
  • ViewModel Testing: Implement patterns for testing ViewModels, including mocking services.
  • Mocking MAUI Services: Strategies for mocking common MAUI interfaces like ISecureStorage and IConnectivity.
  • Running Tests: Commands for executing tests locally and with code coverage.
  • On-Device Testing: Information on running tests directly on emulators or physical devices.

Quick Start

Set up a new xUnit test project for your .NET MAUI application by creating a class library targeting the appropriate TFM and adding the required xUnit and Moq NuGet packages.

Frequently Asked Questions about maui-unit-testing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I set up xUnit testing for a .NET MAUI application?

To set up xUnit testing for .NET MAUI, create a class library targeting the appropriate TFM and add the required xUnit and Moq NuGet packages. This establishes the foundation for running cross-platform mobile tests.

What is the best way to mock MAUI services like ISecureStorage in unit tests?

The best way to mock MAUI services like ISecureStorage and IConnectivity is using the Moq library. This Skill provides strategies for mocking common MAUI interfaces to isolate ViewModels during unit testing.

How do I test ViewModels in .NET MAUI?

Test ViewModels in .NET MAUI by implementing patterns that mock their service dependencies using Moq. This isolates the ViewModel logic, ensuring maintainable and reliable unit tests for cross-platform mobile applications.

Does xUnit work with .NET MAUI for on-device testing?

Yes, xUnit works with .NET MAUI for on-device testing. This Skill provides information on running tests directly on emulators or physical devices, extending beyond local execution to validate cross-platform mobile behavior.

What NuGet packages do I need for a .NET MAUI test project?

You need the xunit, xunit.runner.visualstudio, Microsoft.NET.Test.Sdk, and Moq packages for a .NET MAUI test project. Adding coverlet.collector also enables code coverage collection during local test execution.