Running sequential UI tests causes HttpRequestException after first test run

Hi All.

I have an Xamarin UI test project with bunch of tests. I want to run those tests locally one after another. The first tests goes just fine. However subsequent tests fail on the line where I do configuration

public class AppInitializer
    {
        public static IApp StartApp(Platform platform)
        {
            if(platform == Platform.Android)
            {
                return ConfigureApp
                    .Android
                    .PreferIdeSettings()
                    .InstalledApp("com.MY-APP-BUNDLE-ID")
                    .StartApp(AppDataMode.Clear);
            }
        }
    }

The exception I get is following

System.Net.Http.HttpRequestException : An error occurred while sending the request.
  ----> System.Net.Http.WinHttpException : The connection with the server was terminated abnormally
   at Xamarin.UITest.Shared.Http.HttpClient.SendData(String endpoint, String method, HttpContent content, ExceptionPolicy exceptionPolicy, Nullable`1 timeOut)
   at Xamarin.UITest.Shared.Http.HttpClient.PostUntilExpectedResultReceived(String endpoint, String arguments, String expectedContent, Int32 retries)
   at Xamarin.UITest.Shared.Android.HttpApplicationStarter.Execute(String intentJson)
   at Xamarin.UITest.Shared.Android.LocalAndroidAppLifeCycle.LaunchApp(String appPackageName, ApkFile testServerApkFile, Int32 testServerPort)
   at Xamarin.UITest.Android.AndroidApp..ctor(IAndroidAppConfiguration appConfiguration, IExecutor executor)
   at Xamarin.UITest.Configuration.AndroidAppConfigurator.StartApp(AppDataMode appDataMode)
   at MKopa.Home.Automation.Tests.AppInitializer.StartApp(Platform platform) in C:\Projects\M-Kopa\MKopa.Home\Tests\MKopa.Home.Automation.Tests\AppInitializer.cs:line 12
   at MKopa.Home.Automation.Tests.BaseFeature.BeforeEachTest() in C:\Projects\M-Kopa\MKopa.Home\Tests\MKopa.Home.Automation.Tests\BaseFeature.cs:line 32
--WinHttpException
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Net.Http.WinHttpHandler.<StartRequest>d__103.MoveNext()

I can execute tests one by one, but that's very tedious. Is there a way around this issue?

Sign In or Register to comment.