我正在使用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-使用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:连接被对等方重置
<23340a11bb41423aa895298bf881ed68>:0中的System.Net.Sockets.Socket.EndReceive(System.IAsyncResult asyncResult)[0x00012]中的2019-01-17T14:11:33.9322710Z
<23340a11bb41423aa895298bf881ed68>:0中的System.Net.Sockets.NetworkStream.EndRead(System.IAsyncResult asyncResult)[0x00057]中的2019-01-17T14:11:33.9340560Z
2019-01-17T14:11:33.9358740Z-内部异常堆栈跟踪结束-
<23340a11bb41423aa895298bf881ed68>:0中的System.Net.Sockets.NetworkStream.EndRead(System.IAsyncResult asyncResult)[0x0009b]中的2019-01-17T14:11:33.9377100Z
2019-01-17T14:11:33.9398100Z位于System.IO.Stream + <> c.b__43_1(System.IO.Stream流,System.IAsyncResult asyncResult)[0x00000]在<98fac219bd4e453693d76fda7bd96ab0>:0中
2019-01-17T14:11:33.9415720Z at System.Threading.Tasks.TaskFactory
1+FromAsyncTrimPromise
1 [TResult,TInstance] .Complete(TInstance thisRef,System.Func`3 [T1,T2,TResult] endMethod,System.IAsyncResult asyncResult,System .Boolean requireSynchronization)[0x00000]在<98fac219bd4e453693d76fda7bd96ab0>:0中
有时是这个错误:
SetUp:Xamarin.UITest.XDB.Exceptions.DeviceAgentException:无法结束会话:发送请求时发生错误
System.Net.Http.HttpRequestException:发送请求时发生错误
System.Net.WebException:无法从传输连接中读取数据:连接被对等方重置。
System.IO.IOException:无法从传输连接中读取数据:连接被对等方重置。
System.Net.Sockets.SocketException:对等重置连接
有什么解决方案?进行nuget软件包的版本困惑使我走了这么远,所有测试都在此之外进行。
可能会进行虚拟测试,但使用该测试进行大量构建将永远不会处于“成功”状态,因为该测试失败=(
我能够找到解决此问题的方法,并且可以找到设备代理未连接到被测应用程序的任何问题。
public static IApp StartApp(Platform platform)
{
if (platform == Platform.iOS)
{
try
{
return ConfigureApp.iOS
.InstalledApp("com.example")
#if DEBUG
.Debug()
#endif
.StartApp();
}
catch
{
return ConfigureApp.iOS
.InstalledApp("com.example")
#if DEBUG
.Debug()
#endif
.ConnectToApp();
}
}
用通俗易懂的语言:“如果您尝试启动该应用程序,但是出了点问题,请尝试查看被测试的应用程序是否已经启动并连接到它”
注:由于https://stackoverflow.com/users/1214857/iupchris10在评论中提到的,注意,该方案是,当你运行测试连续,而的startApp通话将理论上可靠地关闭应用程序,用点如果失败是重新连接,如果没有重新连接,并且您正在连续运行测试,那么您将以处于连接状态的任何状态简单地连接到正在运行的应用程序实例。这种方法没有任何帮助。Xamarin的StartApp将引发Exception而不是类型异常,因此要缓解此状况,您将需要解析InnerException.Message并保留预期的失败表。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句