Commits


Caroline Zhu authored and GitHub committed 9f9fcf74ff5
[Mobile] Add BrowserStack Android MAUI Test (#23383) ### Description Add test project that will perform an automated UI test that runs the unit tests on Android. ### Motivation - Enables end-to-end on-device MAUI unit testing which we want to add to the packaging pipelines ### Context Microsoft.ML.OnnxRuntime.Tests.MAUI uses DeviceRunners.VisualRunners to allow running the unit tests (found in Microsoft.ML.OnnxRuntime.Tests.Common) across multiple devices. DeviceRunners.VisualRunners provides a simple UI with a button that will run the unit tests and a panel with the unit test results. In order to automate the process of running the unit tests across mobile devices, Appium is used for UI testing orchestration (it provides a way to interact with the UI), and BrowserStack automatically runs these Appium tests across different mobile devices. This project does not include the capability to start an Appium server locally or attach to a local emulator or device. ## Build & run instructions ### Requirements * A BrowserStack account with access to App Automate * You can set BrowserStack credentials as environment variables as shown [here](https://www.browserstack.com/docs/app-automate/appium/getting-started/c-sharp/nunit/integrate-your-tests#CLI) * ONNXRuntime NuGet package 1. You can either download the [stable NuGet package](https://www.nuget.org/packages/Microsoft.ML.OnnxRuntime) then follow the instructions from [NativeLibraryInclude.props file](../Microsoft.ML.OnnxRuntime.Tests.Common/NativeLibraryInclude.props) to use the downloaded .nupkg file 2. Or follow the [build instructions](https://onnxruntime.ai/docs/build/android.html) to build the Android package locally * The dotnet workloads for maui and maui-android, which will not always automatically install correctly 1. `dotnet workload install maui` 2. `dotnet workload install maui-android` * [Appium](https://appium.io/docs/en/latest/quickstart/) and the [UiAutomator2 driver](https://appium.io/docs/en/latest/quickstart/uiauto2-driver/) ### Run instructions 1. Build the Microsoft.ML.OnnxRuntime.Tests.MAUI project into a signed APK. 1. Run the following: `dotnet publish -c Release -f net8.0-android` in the Microsoft.ML.OnnxRuntime.Tests.MAUI directory. 2. Search for the APK files generated. They should be located in `bin\Release\net8.0-android\publish`. 3. If they're in a different location, edit the `browserstack.yml` file to target the path to the signed APK. 2. Ensure you've set the BrowserStack credentials as environment variables. 3. Run the following in the Microsoft.ML.OnnxRuntime.Tests.Android.BrowserStack directory: `dotnet test` 4. Navigate to the [BrowserStack App Automate dashboard](https://app-automate.browserstack.com/dashboard/v2/builds) to see your test running!