Commit graph

3 commits

Author SHA1 Message Date
Caroline Zhu
2fc75a45a2
[mobile] Add Android BrowserStack test project back (#23551)
## Description
Follow-up for #23383 and #23474

* Adds android BrowserStack test back in
* Modifies MAUI csproj file to build into an APK


### Motivation and Context
There were 2 issues with the previous PRs:
1. The updated MAUI .csproj file configuration failed when building to
iOS and MacCatalyst. This caused problems in the packaging pipeline
because we build all C# projects in the .soln file in the packaging
pipeline. Removed the Mac & iOS build targets for now

3. The previous MAUI .csproj file configuration did not build into an
APK. It was missing the `<OutputType>` XAML tag and the Android package
type XAML tag.
2025-02-04 14:39:50 -08:00
Caroline Zhu
d00ae325ce
Revert "[Mobile] Add BrowserStack Android MAUI Test (#23383)" (#23474)
This reverts commit 9f9fcf74ff.

### Motivation and Context
- NuGet packaging pipelines failing with this error:
```Files\dotnet\packs\Microsoft.NET.Runtime.MonoTargets.Sdk\8.0.12\Sdk\RuntimeComponentManifest.targets(3,5):
error : Empty ResolveFrameworkReference.RuntimePackPath while trying to
read runtime components manifest. ResolvedFrameworkReference available:
{ Microsoft.NETCore.App, RuntimePackPath: }```
2025-01-23 21:48:27 -08:00
Caroline Zhu
9f9fcf74ff
[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!
2025-01-22 10:57:09 -08:00