Wealthfront

Wealthfront: How 40 Lines of Code Sped Up iOS End to End Tests by over 50%

Original post How 40 Lines of Code Sped Up iOS End to End Tests by over 50%

Article Summary

Wealthfront's iOS team cut E2E test time in half with just 40 lines of code. The culprit? A 1-second polling interval nobody questioned.

With 30k unit tests and nearly 1k E2E tests, Wealthfront's iOS team prioritized reliability over speed using XCTWaiter. But they discovered Apple's polling mechanism was blocking for a full second between checks, a design from the pre-M-series era that was killing performance.

Key Takeaways

Critical Insight

By replacing Apple's outdated XCTWaiter with a custom polling mechanism using exponential backoff, Wealthfront achieved 50% faster E2E tests on CI and 80% locally.

Continue reading

What This Article Covers

Problem

Wealthfront's iOS E2E tests had a tradeoff between speed and reliability. Immediate assertions ran fast but became flaky when tests ran in parallel. Waiting assertions with XCTWaiter were stable but slow because Apple's polling interval is locked at 1 second, which blocked the test runner.

Solution

The team built their own version of XCTWaiter with exponential backoff starting at 0.2 seconds and capping at 2 seconds. They also added a pre-check that skips polling entirely if the condition already passes. This prevented CPU overload on the M1 Mac Minis that were running four test processes at once.

Impact

The custom polling cut CI pipeline execution time in half while keeping tests stable in parallel environments. Local test runs saw 80% faster execution without crashes or reliability issues.

The appendix includes drop-in helper functions you can use to implement this in your own iOS test suite today.

This page summarizes “How 40 Lines of Code Sped Up iOS End to End Tests by over 50%” by Wealthfront, published Mar 17, 2025. All credit for the original work goes to the authors.

Read the original on eng.wealthfront.com (opens in new tab)

AI tools for iOS

Browse all AI tools →