0

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);
        }
    }

}
  • Platform is obsolete. If you are using up to date mono you should use Device.RuntimePlatform == Device.Android. Currently posted code prevents me for further speculations – Adlorem Oct 05 '19 at 13:21
  • Is your problem resolved? – Saamer Oct 07 '19 at 16:03
  • I am still having problems I have updated the post with the code in AppManager. –  Oct 07 '19 at 16:13
  • Do you mean the test app launched successfully and then it looks like stuck? If the app is not launch successfully, I would recommend you check the path of apk, look at [this thread](https://stackoverflow.com/questions/42216636/xamarin-ui-test-unable-to-load-the-native-apk-path-that-i-point-to). – nevermore Oct 09 '19 at 06:02

0 Answers0