locked
Xamarin UITest does not clean my app on iOS RRS feed

  • Question

  • User382262 posted

    Hi all,

    When I ran my tests on android the app always starts at the beginning and no prev configurations are set. But with iOS the app always starts with the page where it last has been. So when I ran test A and i'm on screen X and after that I ran test B then the app will start at screen X instead of the initial beginning screen.

    I already set the AppDataMode to clear but this didn't do the trick.

    Thanks in advance!

    Thursday, February 7, 2019 9:45 AM

Answers

  • User21936 posted

    I was just able to verify this issue with a simple Xamarin.Forms app. I reached out to see if this is a known issue or not.

    Turns out it is a known issue and the workaround is to set an Environment variable in the AppInitializer, e.g.:

    public class AppInitializer
    {
        public static IApp StartApp(Platform platform)
        {
            if (platform == Platform.Android)
            {
                return ConfigureApp.Android.StartApp();
            }
    
            Environment.SetEnvironmentVariable("UITEST_FORCE_IOS_SIM_RESTART", "1"); // <----  Add this line
    
            return ConfigureApp.iOS.StartApp();
        }
    }
    

    https://github.com/King-of-Spades/AppCenter-Test-Samples/blob/master/Xamarin.UITest/UITestDemo/UITestDemo.UITest/AppInitializer.cs#L36

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Friday, February 8, 2019 1:29 AM

All replies

  • User21936 posted

    @llaurenss

    Support for UI test is through App Center support portal: https://intercom.help/appcenter/getting-started/getting-help-with-app-center

    Friday, February 8, 2019 12:49 AM
  • User21936 posted

    I was just able to verify this issue with a simple Xamarin.Forms app. I reached out to see if this is a known issue or not.

    Turns out it is a known issue and the workaround is to set an Environment variable in the AppInitializer, e.g.:

    public class AppInitializer
    {
        public static IApp StartApp(Platform platform)
        {
            if (platform == Platform.Android)
            {
                return ConfigureApp.Android.StartApp();
            }
    
            Environment.SetEnvironmentVariable("UITEST_FORCE_IOS_SIM_RESTART", "1"); // <----  Add this line
    
            return ConfigureApp.iOS.StartApp();
        }
    }
    

    https://github.com/King-of-Spades/AppCenter-Test-Samples/blob/master/Xamarin.UITest/UITestDemo/UITestDemo.UITest/AppInitializer.cs#L36

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Friday, February 8, 2019 1:29 AM
  • User382262 posted

    HI @JGoldberger

    Well after I used another simulator it didn't occure anymore but never the last I added the line and it didn't happend again. Anyway thanks for the help!

    Friday, February 8, 2019 8:26 AM