dotnet/maui/run-device-tests
Claude Code and agent skill by dotnet/maui
- community
Checking that the SKILL.md file is still in the repository.
Build and run .NET MAUI device tests locally with category filtering. Supports iOS, MacCatalyst, Android on macOS; Android, Windows on Windows. Use TestFilter to run specific test categories.
Install
npx vskill@latest install dotnet/maui/run-device-testsSKILL.md
Run Device Tests Skill
Build and run .NET MAUI device tests locally on iOS simulators, MacCatalyst, Android emulators, or Windows.
Platform Support
| Host OS | Supported Platforms | |
|---|---|---|
| macOS | ios, maccatalyst, android | |
| Windows | android, windows |
Tools Required
This skill uses bash together with pwsh (PowerShell 7+) to run the PowerShell scripts. Requires:
xharness- Global dotnet tool for running tests on iOS/MacCatalyst/Androiddotnet- .NET SDK with platform workloads installed- iOS/MacCatalyst: Xcode with iOS simulators
- Android: Android SDK with emulator
- Windows: Windows SDK
Dependencies
This skill uses shared infrastructure scripts:
.github/scripts/shared/Start-Emulator.ps1- Detects and boots iOS simulators / Android emulators.github/scripts/shared/shared-utils.ps1- Common utility functions
These are automatically loaded by the Run-DeviceTests.ps1 script.
When to Use
- User wants to run device tests locally
- User wants to verify iOS/MacCatalyst/Android/Windows compatibility
- User wants to test on a specific iOS version (e.g., iOS 26)
- User asks "run device tests for Controls/Core/Essentials/Graphics"
- User asks "test on iOS simulator" or "test on Android emulator"
- User asks "run device tests on MacCatalyst"
- User wants to run only specific test categories (e.g., "run Button tests")
Available Test Projects
| Project | Path | |
|---|---|---|
| Controls | src/Controls/tests/DeviceTests/Controls.DeviceTests.csproj | |
| Core | src/Core/tests/DeviceTests/Core.DeviceTests.csproj | |
| Essentials | src/Essentials/test/DeviceTests/Essentials.DeviceTests.csproj | |
| Graphics | src/Graphics/tests/DeviceTests/Graphics.DeviceTests.csproj | |
| BlazorWebView | src/BlazorWebView/tests/DeviceTests/MauiBlazorWebView.DeviceTests.csproj |
Scripts
All scripts are in .github/skills/run-device-tests/scripts/
Run Device Tests (Full Workflow)
Build Only (No Test Run)
Force a Full Rebuild
Use -Rebuild when source files changed after an earlier build in the same worktree, such as an A/B verification run:
List Available Simulators/Emulators
Workflow
- Run tests:
scripts/Run-DeviceTests.ps1 -Project <name> -Platform <platform>automatically detects/boots device, builds, and runs tests - Check results: Look at the console output or
artifacts/log/directory for detailed test results
Output
- Build artifacts:
artifacts/bin/<Project>.DeviceTests/<Configuration>/<tfm>/<rid>/ - Test logs:
artifacts/log/ - Test results summary is printed to console
Prerequisites
xharnessglobal tool:dotnet tool install --global Microsoft.DotNet.XHarness.CLI- .NET SDK with platform workloads
- iOS/MacCatalyst: Xcode with simulators installed
- Android: Android SDK with emulator configured
- Windows: Windows SDK
- For iOS 26: macOS Tahoe (26) with Xcode 26
Examples
Notes
- The script automatically detects and boots an iOS simulator / Android emulator using the shared Start-Emulator.ps1 infrastructure
- Default iOS simulator is iPhone Xs with iOS 18.5 (same as UI tests)
- Default Android emulator priority: API 30 Nexus > API 30 > Nexus > First available
- MacCatalyst runs directly on the Mac (no simulator needed)
- Windows tests run directly on the local machine
- Simulator/emulator selection and boot logic is handled by
.github/scripts/shared/Start-Emulator.ps1 - xharness manages test execution and reporting for iOS/MacCatalyst/Android
- Class-filtered XHarness retries use isolated child output directories; Android also uses a per-run result filename so stale diagnostics or device-side XML cannot be reused
- Windows runs the built device-test app directly and reads its xUnit XML results, matching
eng/devices/windows.cake
Test Filtering
The -TestFilter parameter allows running specific test categories instead of all tests. This is useful for quick iteration during development.
Filter Syntax
| Format | Description | Example | |
|---|---|---|---|
Category=X | Run only category X | Category=Button | |
SkipCategories=X,Y,Z | Skip categories X, Y, Z | SkipCategories=Shell,CollectionView |
Examples
How Test Filtering Works
Test filtering is implemented in src/Core/tests/DeviceTests.Shared/DeviceTestSharedHelpers.cs:
| Platform | How Filter is Passed | How Filter is Read | |
|---|---|---|---|
| iOS/MacCatalyst | --set-env=TestFilter=... | NSProcessInfo.ProcessInfo.Environment["TestFilter"] | |
| Android | --arg TestFilter=... | MauiTestInstrumentation.Current.Arguments.GetString("TestFilter") | |
| Windows Controls | App argument selects discovered category index | ControlsHeadlessTestRunner category loop | |
| Windows non-Controls class filter | Per-child NUNIT_SKIPPED_CLASSES plus the normal runner | XHarness ApplicationOptions class include |
The Copilot Gate combines -TestFilter with -IncludeClasses when it knows the exact test class. On Windows, Controls still requires category discovery, while Core, Essentials, Graphics, and BlazorWebView bypass discovery and use XHarness's native class include. The result parser rejects output containing any unrelated class. Exact-class Windows runs, including scoped Controls category runs, are capped at 10 minutes per attempt; the Gate retries a timeout three times before treating repeated target-only timeouts as deterministic evidence.
Available Test Categories
Common categories in Controls.DeviceTests:
Button,Label,Entry,Editor- Individual control testsCollectionView,ListView,CarouselView- Collection controls (heavy)Shell,Navigation,TabbedPage- Navigation tests (heavy)Layout,FlexLayout- Layout testsMemory- Memory leak testsAccessibility- Accessibility testsGesture- Gesture recognition tests
To see all categories, check src/Controls/tests/DeviceTests/TestCategory.cs.
Troubleshooting
Xcode Version Mismatch
If you see errors about Xcode version mismatch (e.g., "Xcode 26.2 installed but 26.0 required"):
MacCatalyst App Bundle Not Found
MacCatalyst apps use display names (e.g., "Controls Tests.app") not assembly names. The script handles this automatically by searching for .app bundles in the output directory.
Android Package Name Issues
Android package names must be lowercase (e.g., com.microsoft.maui.controls.devicetests). The script has a mapping of project names to correct package names.
Test Filter Not Working
- Ensure full rebuild: The test filter code must be compiled into the app. Delete artifacts and rebuild:
``bash rm -rf artifacts/bin/<Project>.DeviceTests pwsh .github/skills/run-device-tests/scripts/Run-DeviceTests.ps1 -Project Controls -Platform android -TestFilter "Category=Button" ``
- Check the console output: Look for
TestFilter: Category=Buttonin the test output to confirm filter was applied.
- Verify category exists: Ensure the category name matches exactly (case-sensitive).
XHarness Device Detection
The script automatically handles XHarness device targeting for iOS and Android:
iOS
- Simulator Boot: Start-Emulator.ps1 detects and boots appropriate iOS simulator
- UDID Extraction: Script extracts simulator UDID from Start-Emulator.ps1 output
- iOS Version Detection: Script queries
xcrun simctlto get iOS version from booted simulator - XHarness Targeting: Passes both
--target ios-simulator-64_VERSIONand--device UDIDto xharness for explicit targeting
MacCatalyst
- Runs directly on the Mac, no device targeting needed
- XHarness uses
--target maccatalyst
Android
- Emulator Boot: Start-Emulator.ps1 detects running device or boots emulator
- Device ID Extraction: Script gets device ID (e.g.,
emulator-5554) - XHarness Targeting: Passes
--device-idto xharness android command
Windows
- No device/emulator needed
- Runs the built device-test app directly and parses
TestResults-*.xml
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryChecking.github/skills/run-device-tests/SKILL.md
Popularity
- Repository stars
- 23,322
- Repository forks
- 1,985
- 7-day trend score
- 50
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/dotnet/maui/run-device-tests)