ios - Xamarin.UITest 无法联系在应用程序中运行的测试后端
问题描述
我正在尝试使用 Xamarin.UITest 测试我的 Xamarin.Forms 应用程序。Android工作正常,但iOS部分有问题。在执行我的第一个测试以进入 REPL 时,我收到以下错误:
SetUp : System.Exception : Unable to contact test backend running in app. A common cause is that the app is not properly linked with Calabash. Please verify that it includes the Calabash component.
奇怪的是,当将应用程序上传到 Microsoft 应用程序中心时,它会开始测试。它只是挂起,因为它找不到我的工具栏项。我想通过在我的 Mac 上进行 iOS 测试来检查 REPL 的有效查询,而我通常在 Windows 上使用 Visual Studio。
我尝试了我在网上找到的解决方案,但没有运气
- 我的 .iOS 项目包括 Xamarin.TestCloud.Agent
- 在 AppDelegate.cs 中,我在 global::Xamarin.Forms.Forms.Init() 之后直接有 Xamarin.Calabash.Start()。
- 我在 UITest 项目中有 NUnit 2.6.4 和 NUnitTestAdapter 2.1.1
- 我正在使用我的 Debug/IPhoneSimulator 配置
我正在从连接到 Mac 的 Windows 上的 Visual Studio 编译一个 .app 文件,并在 Mac 上启动 iOS 测试。
这是我当前的 AppInitializer 代码:
return ConfigureApp.iOS.AppBundle(sPathToiOS).PreferIdeSettings().StartApp();
有时我也会得到一个不同的错误:
SetUp : Xamarin.UITest.XDB.Exceptions.DeviceAgentException : Unable to contact DeviceAgent
----> System.AggregateException : One or more errors occurred.
----> Xamarin.UITest.XDB.Exceptions.DeviceAgentException : Unable to contact DeviceAgent on 127.0.0.1
----> System.Net.Http.HttpRequestException : An error occurred while sending the request
----> System.Net.WebException : Error: ConnectFailure (Connection refused)
----> System.Net.Sockets.SocketException : Connection refused
当启动测试时模拟器没有运行并且启动模拟器需要很长时间时,这似乎会发生。
解决方案
我必须确保我已将应用程序重新部署到我要测试的模拟器上,并且所有必要的步骤都已到位。
具体发生在我身上的是我Xamarin.Calabash.Start()
将AppDelegate.cs
. )。
这将确保应用程序的正确版本在模拟器上。这是在模拟器上测试的唯一方法;在运行测试之前,它不会为您部署应用程序。
推荐阅读
- python - 子进程输出中未正确显示 Unicode 字符
- c - 为什么我无法检索从内部反引号暂停的程序?
- javascript - 如何在保存时将动态设置为查看模式
- rust - 非详尽模式 - Rust 匹配表达式
- rust - 如何在结构中设置一个空值的字段?
- julia - 当函数体中没有指定泛型类型参数时,如何访问它?
- python - 了解如何部署python代码来弹出气球
- spring-boot - MapStruct 不使用 Kotlin 和 Spring Boot 自动装配,使用 Gradle 构建
- angular - 如何使用 *ngFor 在同一个对象上迭代两次?
- r - R 中 exp(mean(log(murders$population))) 的 tidyverse 代码等效