我正在尝试使用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 App Center时,它会启动测试。它只是挂起,因为它找不到我的工具栏。我想通过在Mac上进行iOS测试来检查REPL的有效查询,而我通常在Windows上使用Visual Studio。
我尝试了网上找到的解决方案但没有运气
我正在从连接到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
当启动测试时模拟器未运行并且启动模拟器需要很长时间时,似乎会发生这种情况。
因此,如果有人遇到类似我的类似问题并且遇到这个问题:我的解决方案是将物理设备连接到Mac并在其上运行我的UI-Test。请记住,您必须在设备上的开发人员设置中激活UIAutomation。现在我可以毫无问题地运行我的测试。