【发布时间】:2019-06-11 19:41:19
【问题描述】:
我正在使用 Xamarin.UITest 在真实设备(带有 iOS 12.1 的 iPhone 6s)上测试 Xamarin.iOS 应用程序。 当我运行我的几个 UI 测试时,第一个测试总是会崩溃(不管测试内部发生了什么),因为相同的错误(见下文)。
环境是:
-
Xamarin.UITest 2.2.7
-
NUnitTestAdapter 2.1.1
-
NUnit 2.6.3
-
Xamarin.TestCloud.Agent 0.21.7
设置是:
[SetUp]
public void Setup(){
this.app = ConfigureApp.iOS
.EnableLocalScreenshots()
.InstalledApp("my.app.bundle")
.DeviceIdentifier("My-iPhone6s-UDID-With-iOS12.1")
.StartApp();
}
[Test]
public void FirstTestThatCouldBeEmpty(){
//But doesn't have to be empty to produce the error
}
产生的错误:
2019-01-17T14:11:20.4902700Z 1 - ClearData:> 2019-01-17T14:11:20.4916340Z bundleId: my.app.bundle 2019-01-17T14:11:20.4929580Z deviceId: My-iPhone6s-UDID-With-iOS12.1
2019-01-17T14:11:33.7561260Z 3 - LaunchTestAsync:
2019-01-17T14:11:33.7574050Z deviceId: My-iPhone6s-UDID-With-iOS12.1
2019-01-17T14:11:33.9279420Z 5 - HTTP 请求失败,重试限制达到
2019-01-17T14:11:33.9302300Z 异常:System.Net.Http.HttpRequestException:发送请求时出错 ---> System.Net.WebException:无法从传输连接读取数据:连接由同行重置。 ---> System.IO.IOException:无法从传输连接读取数据:连接被对等方重置。 ---> System.Net.Sockets.SocketException: Connection reset by peer
2019-01-17T14:11:33.9322710Z at System.Net.Sockets.Socket.EndReceive (System.IAsyncResult asyncResult) [0x00012] in :0
2019-01-17T14:11:33.9340560Z 在 System.Net.Sockets.NetworkStream.EndRead (System.IAsyncResult asyncResult) [0x00057] 在 :0
2019-01-17T14:11:33.9358740Z --- 内部异常堆栈跟踪结束 ---
2019-01-17T14:11:33.9377100Z 在 System.Net.Sockets.NetworkStream.EndRead (System.IAsyncResult asyncResult) [0x0009b] 在 :0
2019-01-17T14:11:33.9398100Z 在 System.IO.Stream+c.b__43_1(System.IO.Stream 流,System.IAsyncResult asyncResult)[0x00000] 在 :0
2019-01-17T14:11:33.9415720Z 在 System.Threading.Tasks.TaskFactory
1+FromAsyncTrimPromise1[TResult,TInstance].Complete (TInstance thisRef, System.Func`3[T1,T2,TResult] endMethod, System.IAsyncResult asyncResult, System.Boolean requiresSynchronization) [0x00000] in :0
有时是这个错误:
SetUp:Xamarin.UITest.XDB.Exceptions.DeviceAgentException:无法结束会话:发送请求时出错
System.Net.Http.HttpRequestException : 发送请求时出错
System.Net.WebException:无法从传输连接读取数据:连接被对等方重置。
System.IO.IOException : 无法从传输连接中读取数据:连接被对等方重置。
System.Net.Sockets.SocketException : 对等方重置连接
有什么办法可以解决这个问题? 做 nuget 包的版本难题让我走到了这一步,除了这个之外,所有测试都在工作。
一个虚拟测试是可能的,但是那些测试的无数构建将永远不会处于“成功”状态,因为这个测试失败 =(
【问题讨论】:
-
这可能看起来很奇怪,但是您是否尝试过重新启动设备并再次运行它?
-
这可能和这个问题相同:stackoverflow.com/questions/50024536/…
-
是的,我检查了那个线程,但是你提到的线程中的解决方案是针对模拟器的。我正在物理设备上进行测试。不幸的是,这对我没有帮助。
-
使用 Xamarin UI Test 3.0.0 时我也会遇到这种情况。我还没有找到解决方法。其他也请注意,除了硬件上的不同,这里是“connection reset by peer”而不是“connection denied”
-
我能够通过保存来自 TestFixtureSetup 的异常并在安装过程中抛出它来获得更详细的日志。我将省略您已经粘贴的部分。 pastebin.com/etgzQZLZ 。请注意,这并不总是在 DeleteSessionAsync 期间失败(例如,如果您手动重新启动被测应用),但总是在 LaunchTestAsync 中的某个地方失败。
标签: xamarin xamarin.ios automated-tests ui-testing xamarin.uitest