GrabNgoc Thuyen TrinhProblem & solution
Tackling UI Test Execution Time Imbalance for Xcode Parallel Testing
Summary
Parallel test execution in Xcode can suffer from test time imbalance when tasks finish at significantly different times across parallel simulator workers. Analysis of Xcode scheduling logs shows that the runner groups tests by test class and dispatches all tests from the same class to a single simulator. Attempts to customize the suite by swizzling XCTestSuite fail because made-up suites initialize only after tests are dispatched. To overcome this grouping constraint, unique tokens or test names are appended to the class name component in `-only-testing` command-line arguments. This trick forces Xcode to treat each test as an independent class, successfully distributing individual tests across separate workers.
Context
Xcode parallel testing groups tests by class and assigns all methods in a class to the same simulator worker, causing test execution time imbalance across parallel runners in CI pipelines.
Approach / What changed
Modifying the test identifiers passed to the `-only-testing` argument of `xcodebuild` by inserting unique tokens or method names into the class name segment to prevent Xcode from grouping tests together.
Takeaways
Test time imbalance is measured as the difference between the maximum and minimum worker finish times across parallel execution instances.
Swizzling XCTestSuite methods to split suites cannot bypass worker grouping because custom test suites initialize only after Xcode dispatches tests to workers.
Appending unique strings to class names within `-only-testing` arguments causes Xcode to treat every method as a separate class, enabling single-test dispatching to free workers.
Source and freshness
- Source
- engineering.grab.com
- Published
- Added to Yomu
- Last updated
Summaries are generated from the original by a language model. Check the original before relying on it.
Keep reading
Related reading
The Good Stuff
Paid picks we use ourselves. Links carry a referral code — a subscription through one earns us a commission at no extra cost to you.
The best engineering reads, once a week
One useful email. Unsubscribe anytime.