Mobile app
A small .NET MAUI app with a name field, a Greet button, and a counter, and the tests that drive it on a device. It is the .NET counterpart of upstream’s examples/with-swiftui.
- App:
samples/MobileApp. Every control the tests touch has anAutomationId. - Tests:
samples/MobileApp.E2ETests, derived fromMobileAppTest. - Platform: iOS simulator or Android emulator through
MobileEngine, or the MAUI DevFlow agent.
The tests
Section titled “The tests”GreetingTests has three tests with no model (locators fill and tap) and two where the agent does the same steps and a locator checks the result:
await Agent.ActAsync("get the app to greet {name}", new ActOptions{ Params = new Dictionary<string, object?> { ["name"] = "Grace" },});await Expect.That(Screen.GetByTestId("greeting")).ToHaveTextAsync("Hello, Grace!");DeviceTests uses the Device fixture: send the app home and bring it back, relaunch it, switch to dark mode, and read the foreground app.
Every test is tagged RealModel and Device by AssemblyInfo.cs, including the locator-only ones, because they all need a device. --filter "TestCategory!=RealModel" skips the whole project. To run only the three locator tests, filter by name: --filter "FullyQualifiedName~GreetingTests&FullyQualifiedName!~agent".
Run it
Section titled “Run it”dotnet workload install mauidotnet build samples/MobileApp -f net10.0-ios -r iossimulator-arm64xcrun simctl boot "iPhone 17"dotnet test --project samples/MobileApp.E2ETestsFor Android, build -f net10.0-android -t:SignAndroidPackage, boot an emulator, and set E2E_MOBILE_PLATFORM=android and E2E_MOBILE_APP_PATH to the .apk. The Android path was not run.
Other ways to run it
Section titled “Other ways to run it”| Mode | How |
|---|---|
| Hosted Limrun simulator | LIMRUN_API_KEY=... E2E_MOBILE_PROVIDER=limrun dotnet test --project samples/MobileApp.E2ETests |
| MAUI DevFlow agent (preview) | Launch the Debug build, then E2E_MOBILE_PROVIDER=devflow E2E_DEVFLOW_APP=MobileApp dotnet test --project samples/MobileApp.E2ETests |
The app is not in E2E.slnx, because a machine without the MAUI workload cannot build it. Open samples/MobileApp.slnx in Rider or Visual Studio to see the app and its tests together.