3

我创建了一个简单的 Xamarin.Forms(Portable) 项目并在其中包含 UI 测试项目。但是当我试图在物理设备中运行测试时,它给了我下面提到的异常。

Test Name:  AppLaunches
Test Outcome:   Failed
Result Message: 
SetUp : System.Net.Http.HttpRequestException : An error occurred while sending the request.
  ----> System.Net.WebException : The underlying connection was closed: The connection was closed unexpectedly.
Result StandardOutput:  Full log file: C:\Users\Admin\AppData\Local\Temp\uitest\log-2016-10-22_11-04-53-698.txt
Skipping IDE integration as important properties are configured. To force IDE integration, add .PreferIdeSettings() to ConfigureApp.
Android test running Xamarin.UITest version: 2.0.0.1534
Initializing Android app on device ZX1D63GCCL with installed app: co.veloxcore.UITestSample2
Signing apk with Xamarin keystore.
Skipping installation: Already installed.

这是我的项目的链接:XamarinUITest 日志文件:错误日志

4

1 回答 1

-4

您在使用ModernHttpClient吗?如果您想处理网络异常,也可以使用Polly 。例如:

conferences = await Policy  
      .Handle<WebException>()
      .WaitAndRetry
      (
        retryCount:5, 
        sleepDurationProvider: retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt))
      )
      .ExecuteAsync(async () => await getConferencesTask);

AsyncErrorHandler也是处理异步异常的好工具

于 2016-10-24T11:48:23.217 回答