5

How to run Xamarin UI tests on Android emulator? Always I run my test on real devices, but for CI I need tests on emulator, but I don't know how and google didn't give me a specific answer

public class AppInitializer
{
    private const string ApkPath = @"..\..\..\mob\mob.Droid\bin\Release\myApp.apk";
    private const string AppPath = "mob.iOS.app";

    public static IApp StartApp(Platform platform)
    {
        if (platform == Platform.Android)
        {
            return ConfigureApp
                .Android
                .EnableLocalScreenshots()
                .ApkFile(ApkPath)
                .StartApp();
        }

        return ConfigureApp
            .iOS
            .EnableLocalScreenshots()
            .StartApp();
    }
}
user7405556
  • 73
  • 1
  • 5
  • On my local machine it just needs a started emulator as the only Android device available. So I assume this will work on your CI node as well. – tequila slammer Jan 11 '17 at 16:49

1 Answers1

6

In the documentation and as @tequilaslammer mentions briefly:

Unlike testing on iOS, Xamarin.UITest will not automatically start the Android Emulator. It is necessary to have an Android emulator running or an Android device already connected. If there is more than one device or emulator connected, it will be necessary to provide the serial ID of the device/emulator that should be used to run the test.

Source: https://developer.xamarin.com/guides/testcloud/uitest/intro-to-uitest/#Initializing_AndroidApp

I highly recommend that you read through the complete documentation on this topic as there are a few "gotchas" that will need to be considered for your situation:

https://developer.xamarin.com/guides/testcloud/uitest/intro-to-uitest/

Jon Douglas
  • 13,006
  • 4
  • 38
  • 51