dotnet/maui/write-ui-tests
Claude Code and agent skill by dotnet/maui
- community
Checking that the SKILL.md file is still in the repository.
Creates UI tests for a GitHub issue and verifies they reproduce the bug. Iterates until tests actually fail (proving they catch the issue). Use when PR lacks tests or tests need to be created for an issue.
Install
npx vskill@latest install dotnet/maui/write-ui-testsSKILL.md
Write UI Tests Skill
Creates UI tests that reproduce a GitHub issue, following .NET MAUI conventions. Verifies the tests actually fail before completing.
🛑 BLOCKING REQUIREMENT
YOU CANNOT COMPLETE THIS SKILL UNTIL TESTS FAIL.
A test that passes does NOT prove it catches the bug. You MUST:
- Run tests and observe them FAIL
- If tests pass, iterate on test code until they fail
- Never report "done" with passing tests
If tests keep passing after 3 iterations:
- STOP and ask user: "Tests are passing but they should fail to prove they catch the bug. The test scenario may not correctly reproduce the issue. Should I try a different approach?"
Common mistakes that lead to passing tests:
- Test scenario doesn't match issue reproduction steps
- Checking wrong element or property
- Bug only manifests on specific platform (try different platform)
- Bug requires specific timing or async behavior not captured
- Issue description is incomplete - may need to ask user for clarification
When to Use
- ✅ PR has no tests and needs them
- ✅ Issue needs a reproduction test before fixing
- ✅ Existing tests don't adequately cover the bug
Required Input
Before invoking, ensure you have:
- Issue number (e.g., 33331)
- Issue description or reproduction steps
- Platforms affected (iOS, Android, Windows, MacCatalyst)
Platform selection guidance:
- Start with the platform mentioned in the issue (often in title or labels)
- If issue says "iOS" or has
platform/iOSlabel → test on iOS first - If issue says "Android" or has
platform/Androidlabel → test on Android first - If issue affects "All" platforms → start with Android (faster emulator boot)
- If test passes on one platform, try another before concluding test is wrong
Workflow
Step 1: Read the UI Test Guidelines
This contains the authoritative conventions for:
- File naming (
IssueXXXXX.csfor C#-only, orIssueXXXXX.xaml/.xaml.csfor XAML) - File locations (
TestCases.HostApp/Issues/,TestCases.Shared.Tests/Tests/Issues/) - Required attributes (
[Issue()],[Category()]) - Test patterns and assertions
Step 2: Create HostApp Page
Location: src/Controls/tests/TestCases.HostApp/Issues/IssueXXXXX.cs
Key requirements:
- Add
AutomationIdto all interactive elements - Use
[Issue()]attribute with tracker, number, description, platform - Keep UI minimal - just enough to reproduce the bug
Note: XAML is optional. C#-only pages (as shown above) are simpler and preferred for most test scenarios. Use XAML only when the bug specifically relates to XAML parsing or markup behavior.
Step 3: Create NUnit Test
Location: src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/IssueXXXXX.cs
Key requirements:
- Inherit from
_IssuesUITest - Use same
AutomationIdvalues as HostApp - Add ONE
[Category()]attribute (checkUITestCategories.csfor options) - Use
App.WaitForElement()before interactions
Step 4: Verify Files Compile
Step 5: Verify Tests Reproduce the Bug ⚠️ CRITICAL
Tests must FAIL to prove they catch the bug. Run verification:
Replace <platform> with android, ios, or maccatalyst based on the issue's affected platforms.
The script auto-detects that only test files exist (no fix files) and runs in "verify failure only" mode.
Why FAIL = success? The test must fail NOW (before the fix) to prove it catches the bug. After the fix is applied, it should pass. A test that passes now proves nothing.
If tests FAIL → ✅ Success! Tests correctly reproduce the bug. Proceed to Output.
If tests PASS → ❌ STOP. Test doesn't catch the bug. Iterate:
- Re-read the issue reproduction steps - Is your test doing exactly what the issue describes?
- Check if you're testing the right thing - Are you asserting on the correct element/property?
- Try a different platform - Bug may only manifest on iOS vs Android
- Add debug output - Use
Console.WriteLinein HostApp to trace execution - Simplify - Remove complexity until you isolate the bug behavior
- After 3 failed iterations, STOP and ask user:
> "Tests are passing after 3 iterations. This means either: (a) my test scenario doesn't correctly reproduce the bug, (b) the bug may already be fixed on this branch, or (c) I'm missing something from the issue description. How would you like me to proceed?"
Common reasons tests pass when they shouldn't:
| Symptom | Likely Cause | Fix | |
|---|---|---|---|
| Test passes on all attempts | Test scenario doesn't match bug | Re-read issue reproduction steps carefully | |
| Test asserts pass but bug exists | Asserting wrong property/element | Check what exactly the bug affects | |
| Works on Android, fails on iOS | Bug is platform-specific | Try both platforms | |
| Bug involves timing | Race condition not captured | Add delays or event handlers | |
| Bug involves navigation | Page lifecycle not exercised | Ensure pages are actually pushed/popped |
Do NOT mark this skill complete until tests FAIL.
Output
⚠️ ONLY use this output format if tests FAIL. If tests pass, you have not completed this skill.
After completion (tests verified to fail), report:
If tests PASS after multiple iterations, report instead:
Common Patterns
Testing Property Changes
Testing Layout/Positioning
Testing Visual State (Screenshots)
Testing Platform-Specific Behavior
iOS Device Selection
When running tests on iOS, you may need to target a specific device or iOS version:
Finding different device/version combinations:
Pre-Run Checklist
Before running verify-tests-fail.ps1, confirm:
- [ ] HostApp file exists:
TestCases.HostApp/Issues/IssueXXXXX.cs - [ ] NUnit test file exists:
TestCases.Shared.Tests/Tests/Issues/IssueXXXXX.cs - [ ]
[Issue()]attribute present with all parameters - [ ] All
AutomationIdvalues match between HostApp and test - [ ] Test inherits from
_IssuesUITest - [ ] ONE
[Category()]attribute fromUITestCategories.cs
References
- Full conventions:
.github/instructions/uitests.instructions.md - Category list:
src/Controls/tests/TestCases.Shared.Tests/UITestCategories.cs - Example tests:
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/
Security
- Security scanPassed, 95 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/write-ui-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/write-ui-tests)