[英]Xamarin UI tests succeed on emulator but fail on App Center due to a TaskCancelledException (request time-out)
I'm having a problem in running Xamarin UI tests on AppCenter.我在 AppCenter 上运行 Xamarin UI 测试时遇到问题。 There's
Setup
and TearDown
methods that are supposed to run before and after each test respectively. Setup
和TearDown
方法应该分别在每次测试之前和之后运行。 During setting up and tearing down, I send a request to our server to satisfy the test conditions for that test case.在设置和拆除期间,我向我们的服务器发送一个请求以满足该测试用例的测试条件。 Whenever we run these tests on our Android device emulator, it runs smoothly;
每当我们在我们的 Android 设备仿真器上运行这些测试时,它运行顺畅; however, when the same tests run on app center, they give out an exception that indicates that the request timed-out;
但是,当在应用中心运行相同的测试时,它们会发出一个异常,指示请求超时; exception type is essentially
TaskCancelledException
.异常类型本质上是
TaskCancelledException
。 Since Setup
and TearDown
methods cannot be marked async
in Xamarin UI tests, I just wait for the task to complete using Nito.AsyncEx.AsyncContext.Run
(GitHub repo: https://github.com/StephenCleary/AsyncEx/wiki/AsyncContext ).由于在 Xamarin UI 测试中无法将
Setup
和TearDown
方法标记为async
,我只需使用Nito.AsyncEx.AsyncContext.Run
等待任务完成(GitHub repo: https://github.com/StephenCleary/AsyncEx/wiki/AsyncContext ) . I would've thought it's an issue in that repo if it failed to run on my Android emulator.如果它无法在我的 Android 模拟器上运行,我会认为这是该仓库中的一个问题。 I would've thought it's an issue on our servers if the run on the emulator wasn't pointed to the servers.
如果模拟器上的运行没有指向服务器,我会认为这是我们服务器上的问题。 But since it's pointed to our servers (not a local environment), and since it runs smoothly on my Android emulator, I hereby believe the issue is on Microsoft's app center test cloud.
但是由于它指向我们的服务器(不是本地环境),并且由于它在我的 Android 模拟器上运行顺利,因此我认为问题出在微软的应用中心测试云上。
I'd appreciate any help or suggestions.我将不胜感激任何帮助或建议。
Add time out添加超时
HttpClient client = new HttpClient();
client.Timeout = TimeSpan.FromMinutes(5);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.