gpt4 book ai didi

xamarin - 使用 Xamarin.UITest 测试我的 Xamarin.Forms iOS 应用程序 : The first test always fails

转载 作者:行者123 更新时间:2023-12-02 16:43:07 24 4
gpt4 key购买 nike

我正在使用 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.bundle2019-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 request failed, retry limit hit

2019-01-17T14:11:33.9302300Z Exception: System.Net.Http.HttpRequestException: An error occurred while sending the request ---> System.Net.WebException: Unable to read data from the transport connection: Connection reset by peer. ---> System.IO.IOException: Unable to read data from the transport connection: Connection reset by peer. ---> 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 <23340a11bb41423aa895298bf881ed68>:0

2019-01-17T14:11:33.9340560Z at System.Net.Sockets.NetworkStream.EndRead (System.IAsyncResult asyncResult) [0x00057] in <23340a11bb41423aa895298bf881ed68>:0

2019-01-17T14:11:33.9358740Z --- End of inner exception stack trace ---

2019-01-17T14:11:33.9377100Z at System.Net.Sockets.NetworkStream.EndRead (System.IAsyncResult asyncResult) [0x0009b] in <23340a11bb41423aa895298bf881ed68>:0

2019-01-17T14:11:33.9398100Z at System.IO.Stream+<>c.b__43_1 (System.IO.Stream stream, System.IAsyncResult asyncResult) [0x00000] in <98fac219bd4e453693d76fda7bd96ab0>:0

2019-01-17T14:11:33.9415720Z at System.Threading.Tasks.TaskFactory1+FromAsyncTrimPromise1[TResult,TInstance].Complete (TInstance thisRef, System.Func`3[T1,T2,TResult] endMethod, System.IAsyncResult asyncResult, System.Boolean requiresSynchronization) [0x00000] in <98fac219bd4e453693d76fda7bd96ab0>:0

有时会出现这样的错误:

SetUp : Xamarin.UITest.XDB.Exceptions.DeviceAgentException : Unable to end session: An error occurred while sending the request

System.Net.Http.HttpRequestException : An error occurred while sending the request

System.Net.WebException : Unable to read data from the transport connection: Connection reset by peer.

System.IO.IOException : Unable to read data from the transport connection: Connection reset by peer.

System.Net.Sockets.SocketException : Connection reset by peer

有什么办法可以解决这个问题吗?做 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 并保留预期失败表。

关于xamarin - 使用 Xamarin.UITest 测试我的 Xamarin.Forms iOS 应用程序 : The first test always fails,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54238759/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com