Reputation: 73
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();
}
}
Upvotes: 5
Views: 2869
Reputation: 13176
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/
Upvotes: 6