Token导航 LogoToken导航TokenDH.com
研究检索执行命令github未标认证来源可访问许可证需确认审计通过

run-device-tests运行设备测试

Agent Skill

用于辅助测试设计、自动化测试、用例整理和回归验证。它适合让 Agent 编写单元测试、端到端测试、测试计划或根据失败日志定位问题。使用时需要确认项目测试框架、运行命令和夹具数据,避免为了通过测试而改坏真实逻辑;涉及浏览器或外部服务时,应区分本地模拟、测试环境和生产环境。

总安装

753

周安装

32

GitHub Stars

23,218

下载量

264
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:run-device-tests(运行设备测试)
来源仓库:https://github.com/dotnet/maui
仓库路径:skills/run-device-tests
安装命令:
npx skills add https://github.com/dotnet/maui --skill run-device-tests
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/dotnet/maui --skill run-device-tests

简介

用于辅助测试设计、自动化测试、用例整理和回归验证。

  • 适合让 Agent 编写单元测试、端到端测试、测试计划或根据失败日志定位问题。
  • 使用时需要确认项目测试框架、运行命令和夹具数据,避免为了通过测试而改坏真实逻辑。
  • 涉及浏览器或外部服务时,应区分本地模拟、测试环境和生产环境。
  • run-device-tests 属于研究检索类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

Run Device Tests Skill

Build and run.NET MAUI device tests locally on iOS simulators, MacCatalyst, Android emulators, or Windows.

Platform Support

Host OSSupported Platforms
macOSios, maccatalyst, android
Windowsandroid, 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/Android
  • dotnet -.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

ProjectPath
Controlssrc/Controls/tests/DeviceTests/Controls.DeviceTests.csproj
Coresrc/Core/tests/DeviceTests/Core.DeviceTests.csproj
Essentialssrc/Essentials/test/DeviceTests/Essentials.DeviceTests.csproj
Graphicssrc/Graphics/tests/DeviceTests/Graphics.DeviceTests.csproj
BlazorWebViewsrc/BlazorWebView/tests/DeviceTests/MauiBlazorWebView.DeviceTests.csproj
AIsrc/AI/tests/Essentials.AI.DeviceTests/Essentials.AI.DeviceTests.csproj

Scripts

All scripts are in .github/skills/run-device-tests/scripts/

Run Device Tests (Full Workflow)

# Run Controls device tests on iOS simulator (default on macOS)
pwsh .github/skills/run-device-tests/scripts/Run-DeviceTests.ps1 -Project Controls -Platform ios

# Run Core device tests on MacCatalyst
pwsh .github/skills/run-device-tests/scripts/Run-DeviceTests.ps1 -Project Core -Platform maccatalyst

# Run Controls device tests on Android emulator
pwsh .github/skills/run-device-tests/scripts/Run-DeviceTests.ps1 -Project Controls -Platform android

# Run Controls device tests on Windows (default on Windows)
pwsh .github/skills/run-device-tests/scripts/Run-DeviceTests.ps1 -Project Controls -Platform windows

# Run on specific iOS version
pwsh .github/skills/run-device-tests/scripts/Run-DeviceTests.ps1 -Project Core -Platform ios -iOSVersion 26

# Run with test filter
pwsh .github/skills/run-device-tests/scripts/Run-DeviceTests.ps1 -Project Controls -Platform ios -TestFilter "Category=Button"

# Run other test projects
pwsh .github/skills/run-device-tests/scripts/Run-DeviceTests.ps1 -Project Essentials -Platform android
pwsh .github/skills/run-device-tests/scripts/Run-DeviceTests.ps1 -Project Graphics -Platform maccatalyst
pwsh .github/skills/run-device-tests/scripts/Run-DeviceTests.ps1 -Project BlazorWebView -Platform ios

Build Only (No Test Run)

pwsh .github/skills/run-device-tests/scripts/Run-DeviceTests.ps1 -Project Controls -Platform ios -BuildOnly

List Available Simulators/Emulators

# iOS simulators
xcrun simctl list devices available

# Android emulators
emulator -list-avds

Workflow

  1. Run tests: scripts/Run-DeviceTests.ps1 -Project <name> -Platform <platform> automatically detects/boots device, builds, and runs tests
  2. 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

  • xharness global 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

# Quick test run for Controls on iOS (default on macOS)
pwsh .github/skills/run-device-tests/scripts/Run-DeviceTests.ps1 -Project Controls -Platform ios

# Test on MacCatalyst
pwsh .github/skills/run-device-tests/scripts/Run-DeviceTests.ps1 -Project Controls -Platform maccatalyst

# Test on Android emulator (works on both macOS and Windows)
pwsh .github/skills/run-device-tests/scripts/Run-DeviceTests.ps1 -Project Controls -Platform android

# Test on Windows (default on Windows)
pwsh .github/skills/run-device-tests/scripts/Run-DeviceTests.ps1 -Project Controls -Platform windows

# Test on iOS 26 specifically
pwsh .github/skills/run-device-tests/scripts/Run-DeviceTests.ps1 -Project Controls -Platform ios -iOSVersion 26

# Run only Button category tests on iOS
pwsh .github/skills/run-device-tests/scripts/Run-DeviceTests.ps1 -Project Controls -Platform ios -TestFilter "Category=Button"

# Build for Android without running tests
pwsh .github/skills/run-device-tests/scripts/Run-DeviceTests.ps1 -Project Core -Platform android -BuildOnly

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
  • Windows uses vstest for test execution

Test Filtering

The -TestFilter parameter allows running specific test categories instead of all tests. This is useful for quick iteration during development.

Filter Syntax

FormatDescriptionExample
Category=XRun only category XCategory=Button
SkipCategories=X,Y,ZSkip categories X, Y, ZSkipCategories=Shell,CollectionView

Examples

# Run only Button tests on iOS
pwsh .github/skills/run-device-tests/scripts/Run-DeviceTests.ps1 -Project Controls -Platform ios -TestFilter "Category=Button"

# Run only Button tests on Android
pwsh .github/skills/run-device-tests/scripts/Run-DeviceTests.ps1 -Project Controls -Platform android -TestFilter "Category=Button"

# Skip heavy test categories
pwsh .github/skills/run-device-tests/scripts/Run-DeviceTests.ps1 -Project Controls -Platform ios -TestFilter "SkipCategories=Shell,CollectionView,HybridWebView"

How Test Filtering Works

Test filtering is implemented in src/Core/tests/DeviceTests.Shared/DeviceTestSharedHelpers.cs:

PlatformHow Filter is PassedHow Filter is Read
iOS/MacCatalyst--set-env=TestFilter=...NSProcessInfo.ProcessInfo.Environment["TestFilter"]
Android--arg TestFilter=...MauiTestInstrumentation.Current.Arguments.GetString("TestFilter")
Windows--filter "Category=..."Native vstest filter

Available Test Categories

Common categories in Controls.DeviceTests:

  • Button, Label, Entry, Editor - Individual control tests
  • CollectionView, ListView, CarouselView - Collection controls (heavy)
  • Shell, Navigation, TabbedPage - Navigation tests (heavy)
  • Layout, FlexLayout - Layout tests
  • Memory - Memory leak tests
  • Accessibility - Accessibility tests
  • Gesture - 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"):

# Use -SkipXcodeVersionCheck to bypass validation
pwsh .github/skills/run-device-tests/scripts/Run-DeviceTests.ps1 -Project Controls -Platform ios -SkipXcodeVersionCheck

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

  1. Ensure full rebuild: The test filter code must be compiled into the app. Delete artifacts and rebuild: rm -rf artifacts/bin/<Project>.DeviceTests pwsh.github/skills/run-device-tests/scripts/Run-DeviceTests.ps1 -Project Controls -Platform android -TestFilter "Category=Button"
  2. Check the console output: Look for TestFilter: Category=Button in the test output to confirm filter was applied.
  3. 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

  1. Simulator Boot: Start-Emulator.ps1 detects and boots appropriate iOS simulator
  2. UDID Extraction: Script extracts simulator UDID from Start-Emulator.ps1 output
  3. iOS Version Detection: Script queries xcrun simctl to get iOS version from booted simulator
  4. XHarness Targeting: Passes both --target ios-simulator-64_VERSION and --device UDID to xharness for explicit targeting

MacCatalyst

  • Runs directly on the Mac, no device targeting needed
  • XHarness uses --target maccatalyst

Android

  1. Emulator Boot: Start-Emulator.ps1 detects running device or boots emulator
  2. Device ID Extraction: Script gets device ID (e.g., emulator-5554)
  3. XHarness Targeting: Passes --device-id to xharness android command

Windows

  • No device/emulator needed
  • Uses vstest (dotnet test) for test execution

Why both --target and --device for iOS?

  • XHarness requires --target ios-simulator-64 (or ios-simulator-64_VERSION) to specify platform type
  • Adding --device UDID explicitly tells xharness which simulator to use
  • This combination ensures reliable device selection even on ARM64 Macs where automatic detection can fail

Example xharness invocations:

# iOS with test filter
dotnet xharness apple test \
  --app path/to/app \
  --target ios-simulator-64_18.5 \
  --device 56AE278D-60F7-4892-9DE0-6341357CA068 \
  -o artifacts/log \
  --timeout 01:00:00 \
  -v \
  --set-env=TestFilter=Category=Button

# MacCatalyst with test filter
dotnet xharness apple test \
  --app path/to/app \
  --target maccatalyst \
  -o artifacts/log \
  --timeout 01:00:00 \
  -v \
  --set-env=TestFilter=Category=Button

# Android with test filter
dotnet xharness android test \
  --app path/to/app.apk \
  --package-name com.microsoft.maui.controls.devicetests \
  --device-id emulator-5554 \
  -o artifacts/log \
  --timeout 01:00:00 \
  -v \
  --arg TestFilter=Category=Button

This ensures tests run on the correct device with proper version targeting and filtering.

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

37.35%
按下载量换算99

Claude

29.88%
按下载量换算79

Cursor

19.91%
按下载量换算53

Gemini CLI

9.96%
按下载量换算26

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

执行命令

安装流程涉及命令执行,可能通过 npx skills add https://github.com/dotnet/maui --skill run-device-tests 联网下载 Skill 或依赖。用户安装前应确认命令来源、仓库内容和执行环境。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills