Xamarin UI Testing

128 views Asked by At

I would like to add UnitTest into my Xamarin app, I get the splash screen displaying on the Andriod emulator and then the landing page loads but the next page it seems to closes the app . I have break point around the Platform.Android and that hits but it never hit the end of that method. I added WaitTimes for 5 minutes and I will get the timeout exception

Any idea why the app closes ?

  static class AppManager
{
    private const string ApkPath = @"C:\pathtoapkfile.apk";

    static IApp app;
    public static IApp App
    {
        get
        {
            if (app == null)
                throw new NullReferenceException("'AppManager.App' not set. Call 'AppManager.StartApp()' before trying to access it.");
            return app;
        }
    }

    static Platform? platform;
    public static Platform Platform
    {
        get
        {
            if (platform == null)
                throw new NullReferenceException("'AppManager.Platform' not set.");
            return platform.Value;
        }

        set { platform = value; }
    }

    public static void StartApp()
    {
        if (Platform == Platform.Android)
        {
            app = ConfigureApp
                .Android
                .ApkFile(ApkPath)
                .WaitTimes(new WaitTimes())
                .StartApp(AppDataMode.Clear);
        }

        if (Platform == Platform.iOS)
        {
            app = ConfigureApp
                .iOS
                .StartApp(AppDataMode.Clear);
        }
    }

}
0

There are 0 answers