AI dev tools —

Depop reduces CI runtime by 80% migrating 10,000 unit tests from XCTest to Swift Testing

The migration of roughly 10,000 unit tests from XCTest to Swift Testing by Depop resulted in a modernization of their testing infrastructure and a substantial decrease in continuous integration…

Depop reduces CI runtime by 80% migrating 10,000 unit tests from XCTest to Swift Testing

The migration of roughly 10,000 unit tests from XCTest to Swift Testing by Depop resulted in a modernization of their testing infrastructure and a substantial decrease in continuous integration runtime.

The team at Depop, including engineer Anastasia Petrova, opted for this transition for multiple reasons. These included the understanding that "Swift Testing is where Apple Development is going," the enhanced capabilities for running tests in parallel, its seamless integration with Swift Concurrency, and the availability of sophisticated features such as test traits, nested suites, and parameterized tests. Furthermore, a goal was to bring uniformity to the codebase by adopting Swift Testing consistently, given that existing tests lacked a shared convention.

A major advantage realized from this shift was the ability to parallelize tests, which led to a notable reduction in the time taken on the CI runner. Because Swift Testing executes tests within the process utilizing Swift Concurrency’s cooperative thread pool, when one test pauses using `await`, another test can utilize that same thread. This architecture is notably better suited for a small Virtual Machine, and early performance measurements indicated an approximate 80% runtime improvement when comparing XCTest without parallelization against Swift Testing with it.

Regarding the involvement of artificial intelligence, the team stated that the agents only provided supplemental support during the migration process. The preference was for a manual method based on syntax, leveraging `swift-testing-revolutionary`, an open-source converter built on SwiftSyntax that enforces Apple's prescribed migration guidelines. The decision not to rely solely on AI stemmed from several concerns: even when given precise directives, the AI exhibited a tendency to make subtle alterations to tests that went beyond mere mechanical mapping. In certain instances, the transformation appeared less like a syntactic change and more like a "rewrite" or a slight refactoring of the tests. Although this alternative approach could generally function adequately and perhaps even yield marginally superior tests, it would significantly complicate the subsequent review cycle.

Despite this, an agent was utilized to manage the entire workflow, encompassing the execution of the conversion script, running the tests, and opening a pull request. If test execution across 100 repetitions showed no signs of errors or instability, the PR received automatic approval; conversely, when tests failed, the agent was directed to correct the test, and the PR was then flagged for human inspection. Petrova detailed that several unforeseen complications surfaced during the migration, such as data races, scenarios where tests passed locally but failed on CI, limitations inherent in the converter, and the overhead associated with PR reviews. Most instances of data races were successfully resolved by assigning each test its own dedicated instance or by employing `@Suite(.serialized)` to temporarily enforce serialization. Failures occurring only on CI were chiefly connected to UI-related tests running on auxiliary threads, a problem which was mitigated by mandating that all UI-related tests be `@MainActor-isolated`. Finally, the automated conversion process did not automatically implement advanced Swift Testing capabilities like parameterized tests, nested suites, or test traits, necessitating a distinct manual refactoring effort.

While Depop employed AI mainly as an orchestrator for its migration, other entities have explored a greater degree of AI integration. For instance, Ibrahim Oktay, an engineer at Sixt, reported rewriting 7,000 unit tests using AI, completing the task in a single afternoon at an AI expenditure of only $106. Oktay indicated that the success of this method rested upon creating a customized conversion agent that incorporated around 1200 migration rules specific to their application's architectural design.

The adoption of these testing frameworks and the integration of automation tools reflect a broader industry trend toward optimizing platform stability and developer velocity. Market participants are increasingly seeking ways to streamline infrastructure maintenance while simultaneously enhancing the reliability guarantees provided by their software platforms.

Why it matters

For infrastructure and platform stability, this migration demonstrates a major shift in testing paradigms toward modern Swift features. The performance gains and standardization efforts are critical for maintaining efficient and reliable build pipelines.

Earlier coverage

Reported by InfoQ.

ai-devtoolsjavascriptcloud

Related coverage

Elsewhere in this edition