locked
xamarin.uitest - test finished with message "Length cannot be less than zero." RRS feed

  • Question

  • User370501 posted

    Version Visual Studio for Mac 8.4.5 Version xamarin.uitest: 3.0.6

    When i use helper class: ``` public class InitApp { public static iOSApp connectApp() { return ConfigureApp.iOS .InstalledApp(Params.bundleId) .EnableLocalScreenshots() .StartApp(Xamarin.UITest.Configuration.AppDataMode.DoNotClear); }

        public static iOSApp startApp()
        {
            return ConfigureApp.iOS
                .InstalledApp(Params.bundleId)
                .EnableLocalScreenshots()
                .StartApp(Xamarin.UITest.Configuration.AppDataMode.DoNotClear);
        }
    }
    

    Test finishes execution with message: "Length cannot be less than zero." (reproduced for android tests), if in the test code repeatedly call one of the methods of the InitApp class. Example: app = InitApp.startApp(); //succeeds app = InitApp.connectApp(); //the test ends with a message "Length cannot be less than zero." OR app = InitApp.startApp(); //succeeds app = InitApp.startApp(); //the test ends with a message "Length cannot be less than zero." ``` In version 3.0.5 does not reproduced

    Thursday, February 13, 2020 7:51 AM

All replies

  • User74 posted

    The code for startApp and connectApp is the same, so it looks like you are trying to .StartApp twice. Maybe that is the issue?

    Thursday, February 13, 2020 5:03 PM
  • User370501 posted

    Don't think. I made a mistake in the example of the InitApp class. ``` public class InitApp { public static iOSApp connectApp() { return ConfigureApp.iOS .InstalledApp(Params.bundleId) .EnableLocalScreenshots() .ConnectToApp(); }

        public static iOSApp startApp()
        {
            return ConfigureApp.iOS
                .InstalledApp(Params.bundleId)
                .EnableLocalScreenshots()
                .StartApp(Xamarin.UITest.Configuration.AppDataMode.DoNotClear);
        }
    }
    

    ```

    Before a TestSuite I do:

    [OneTimeSetUp] public void Init() { app = InitApp.startApp(); }

    Before each test I do:

    [SetUp] public void Setup() { try { app = InitApp.connectApp(); //the test ends with a message "Length cannot be less than zero." } catch { app = InitApp.startApp(); } }

    Friday, February 14, 2020 5:59 AM