2

我已經創建了一個簡單的Xamarin.Forms(Portable)項目,並在其中包含UI Test項目。但是當我試圖在物理設備上運行測試時,它給了我下面提到的異常。System.Net.Http.HttpRequestException異常將在物理設備上運行xamarin 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 日誌文件:Error Log

回答

-2

您在使用使用ModernHttpClient? 如果你想處理網絡異常,你也可以使用Polly。 例如:

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

而且AsyncErrorHandler是處理異步異常

+0

這些都是來自於Xamarin UITest管道異常偉大的工具。我有同樣的問題。我無法將這個答案應用於此問題。 – bojingo

相關問題