简体   繁体   中英

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. There's Setup and TearDown methods that are supposed to run before and after each test respectively. 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; 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 . 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 ). I would've thought it's an issue in that repo if it failed to run on my Android emulator. 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.

I'd appreciate any help or suggestions.

Add time out

 HttpClient client = new HttpClient();
 client.Timeout = TimeSpan.FromMinutes(5);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM