MAUIverse MAUIverse

Testing .NET MAUI Application using Appium and xUnit

Unit tests get a short nod here, with links to videos on setting up xUnit. The main part of the article is UI testing with Appium, an open-source automation tool that supports all .NET MAUI platforms through a single API.

The setup installs Appium and a driver for each platform (uiautomator2, Windows, xcuitest, and mac2), then creates a separate xUnit project for each one. An AppiumSetup class per platform prepares the app. On Android, for example, it creates an emulator and installs the APK, so tests don’t depend on someone clicking around. A shared project holds an AppiumServiceHelper and a BaseTest class that captures screenshots and compares them with stored snapshots. The sample tests wait for launch and compare the screen against AppLaunches.png, then click the Login button and compare again.

There’s one Windows-specific caveat: Appium doesn’t start WinUI apps automatically, so you launch the app yourself or start it with explorer.exe. Running tests on specific runtimes is left for a follow-up article.

View Source →

← Back to Community Feed

}