Aaron Sofaer Aaron Sofaer - 4 months ago 55x
iOS Question

Tests on Bitrise (some consistently, some inconsistently) failing with "AX action" errors

I have a number of tests that I've written for an pretty substantial app (the app's been around for a few years longer than I have at this company) in the XCUITest framework. All of the tests pass consistently on my laptop and also the laptops of the other engineers.

When running tests on Bitrise, the first UI test fails every time on the setup phase with the following message:

testFixtureAttachment, UI Testing Failure - Failed to perform AX action for monitoring the animations of (app), error: Error -25204 performing AXAction 2043

Other tests usually pass but sometimes fail with errors such as:

UI Testing Failure - Failed to perform AX action for monitoring the event loop of (app), error: Error -25204 performing AXAction 2042

UI Testing Failure - Failed to scroll to visible (by AX action) TextField 0x7fe800f9fa20: traits: ... error: Error -25204 performing AXAction 2003

How can I resolve this so that, at a minimum, I don't have my first test always failing on setup?


Per feedback from the XCUITest team, this is happening because the simulator is CPU-starved and AX Action is timing out when spinning up the app. I was able to reproduce this on my own machine (which did not normally exhibit the failure) by using Power Management to step down my CPU.

Increasing the CPU allocation in Bitrise is the obvious solution. However, there is another, bizarre solution!

Immediately before the setup function for the tests, I have the following line:

let app = XCUIApplication()

This allows my various tests to call app. instead of the longer, full syntax.

Removing this line was found to prevent the error from occurring. This was found via this Apple Developer forum thread:


So... hopefully that fixes this for other people, but it fixed it for me.