Test A WinUI App

1. Move Logic Out Of The UI

Put pure logic in a library:

src/MyApp.Core
tests/MyApp.Core.Tests

Run it with normal .NET tests:

dotnet test .\tests\MyApp.Core.Tests\MyApp.Core.Tests.csproj

2. Use WinUI Unit Test App For XAML

For XAML runtime tests, create a WinUI Unit Test App in Visual Studio and use [UITestMethod]:

[UITestMethod]
public void CanCreateControl()
{
    var button = new Microsoft.UI.Xaml.Controls.Button { Content = "Save" };
    Assert.AreEqual("Save", button.Content);
}

3. Add UI Automation Hooks

<Button
    Content="Save"
    AutomationProperties.AutomationId="SaveButton" />

Use Appium with the Windows driver for end-to-end UI tests when manual smoke is not enough.

4. Check Accessibility

Run Accessibility Insights for Windows on important flows. Fix missing labels, focus order, keyboard access, and automation tree problems before release.

5. Test WebView2 Separately

Use Playwright for complex web content inside WebView2. This does not replace native shell testing.