Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run Xamarin UI tests on Android emulator

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();
    }
}
like image 933
user7405556 Avatar asked Jan 11 '17 16:01

user7405556


People also ask

How do I run xamarin UI Test?

To run the test on the application we have to simply build the Xamarin. UI test project and then the project. This will simply run all the test cases present inside the test class or if we want to run the specific test case then we have to select that particular test case and run it.

How do I test xamarin app?

Develop the feature in the Android or iOS application. Write the tests and run them locally to verify functionality. Create a new Test Run in App Center Test, or use an existing Test Run. Compile the IPA or APK and then upload it along with the tests to App Center Test.

How do I write unit test cases in xamarin?

Best way to write Unit TestThe unit test should be independent. Code coverage of testing code should be above 85%. The unit test should be simple as there is no confusion of correctness of unit test code. Execution of unit test should be fast and generate an accurate result.


1 Answers

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/

like image 199
Jon Douglas Avatar answered Sep 25 '22 01:09

Jon Douglas