Xamarin UI tests succeed on emulator but fail on App Center due to a TaskCancelledException (request time-out)

305 Views Asked by At

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.

1

There are 1 best solutions below

0
On

Add time out

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