Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode 8 UI Testing Taking Very Long

I'm writing UI tests in XCode 8 for a very complicated app. I'm discovering several issues, one of them being that each test I run takes several minutes.

The flow for the particular test I'm running isn't even that complicated.

I get many "Wait for app to idle" messages.

Does anyone know why the tests take so long to run, or do you have any suggestions on how I can speed them up? The WWDC demo was basically instant, but that was a very simple app.

Here's an example of what I see, and how long it takes. (The test is also still running!)

t =   504.16s         Wait for app to idle
t =   625.29s         App animations complete notification not received, will attempt to continue.
t =   625.30s         Synthesize event
t =   625.67s         Wait for app to idle

Thanks!

Update: When I slightly interact with the app, while keeping the elements I need visible, like by pulling on a tableview, the tests continue.

like image 327
ArielSD Avatar asked Dec 05 '16 20:12

ArielSD


2 Answers

Thanks @Oletha - I found the issue, which may be specific to this app:

After deleting large amounts of code at a time to see where the issue was, we found that we were calling beginRefreshing and endRefreshing on a subclass of UIRefreshControl, on consecutive lines.

Something about that stalled the UI, enough to hold the app in "Wait for app to idle" for minutes.

We replaced those two lines with a custom method, and now tests are running normally.

like image 82
ArielSD Avatar answered Jan 04 '23 16:01

ArielSD


The framework will wait for the app to become static, so if any views are animating or any activity indicators are shown, possibly including the network activity indicator in the status bar, the framework will hang until the app is still. This is to prevent race conditions with animations and components loading while the UI tests run.

If you think it's OK to override some of this behaviour to speed up your UI tests, you can try experimenting with removing activity indicators.

like image 44
Oletha Avatar answered Jan 04 '23 16:01

Oletha