Lessons Learned from Migrating Unit Tests from XCTest to Swift Testing

TL;DR · AI 摘要
Lessons Learned from Migrating Unit Tests from XCTest to Swift Testing - InfoQ InfoQ Homepage News Lessons Learned from...
核心要点
- 主题聚焦:Lessons Learned from Migrating Unit Tests from X
- 来源:InfoQ,建议结合原文判断细节。
- AI 分析暂不可用,本条为保底评分与摘要。
Lessons Learned from Migrating Unit Tests from XCTest to Swift Testing - InfoQ
InfoQ Homepage News Lessons Learned from Migrating Unit Tests from XCTest to Swift Testing
Mobile
QCon AI New York (Dec 15–16): Production AI lessons from senior engineers.
Lessons Learned from Migrating Unit Tests from XCTest to Swift Testing
Dec 02, 2026 2 min read
by
- Sergio De Simone
#### Follow us on
Youtube
232K Followers
26K Followers
New
RSS
19K Readers
X
57.1k Followers
21K Likes
Bluesky
Listen to this article -
0:00
Audio ready to play
Your browser does not support the audio element.
Normal
1.25x
1.5x
Like
new dropdown rading list
- Reading list
Depop migrated approximately 10,000 unit tests from XCTest to Swift Testing with partial assistance of coding agents, modernizing its testing infrastructure and substantially reducing CI runtime.
According to Depop engineer Anastasia Petrova, team decided to migrate for several reasons, including the recognition that "Swift Testing is where Apple Development is going", better support for parallel execution, first-class integration with Swift Concurrency, and advanced features like parameterized tests, nested suites, and test traits. Another objective was to standardize the use of Swift Testing across the codebase, as existing tests did not follow any agreed-upon convention.
A key benefit of the migration was test parallelization, which brought a significant reduction in execution time on the CI runner:
Swift Testing runs tests in-process on Swift Concurrency’s cooperative thread pool, so when one test suspends on await, another test uses that thread. That is a much better fit for a small VM, and our early benchmarks showed roughly an 80% runtime improvement between XCTest with no parallelization and Swift Testing with it.
As mentioned, AI agents played only a supporting role in the migration. The team preferred a manual, syntax-based approach based on swift-testing-revolutionary , an open-source SwiftSyntax-based converter enforcing Apple's migration guidance . There were several reasons why the team chose not to rely entirely on AI for the migration:
Even with strict instructions, AI tended to subtly modify tests beyond the mechanical mapping. In some cases, the conversion looked less as a syntactic transformation, and more as a "rewrite" or a slight refactoring of tests. While this approach would still work fine in general, and maybe even produces slightly better tests, it would dramatically complicate the review process.
However, an agent orchestrated the whole process, from running the conversion script and executing the tests to opening a PR. When test execution across 100 repetitions revealed no errors or flakiness, and the PR did not include any changes to the codebase, the PR was auto-approved. When test execution failed, the agent was instructed to fix the test and the PR flagged for human review.
Petrova explains that a few unexpected issues arose during the migrations process, including data races, testing passing locally and failing on CI, limitations of the converter, and the overhead of PR review. Most data races where resolved giving each test its own instance or using @Suite(.serialized) to temporarily force serialization. CI-only failures were primarily related to UI-related tests executing on secondary threads, which was addressed by forcing all UI-related tests to be @MainActor -isolated. Finally, automatic conversion did not automatically leverage advanced Swift Testing features like parameterized tests, nested suites, and test traits, which required a separate manual refactoring effort.
While Depop used AI primarily as an orchestrator for its migration, other companies have experimented with a greater degree of AI involvement. For example, Sixt engineer Ibrahim Oktay described how they rewrote 7,000 unit tests using AI, completing the work in a single afternoon at an AI cost of just $106. According to Oktay, the key to this approach was develooping a custom conversion agent equipped with ~1200 migration rules specific to their app's architecture.
main wrapper for authors section
About the Author
section title
main wrapper for each author
#### Sergio De Simone
Show more
Show less
#### This content is in the Mobile topic
##### Related Topics:
- Development
- Swift
- Large language models
- Unit Testing
- Mobile
- AI coding agents
- Xcode
- Continuous Integration
- iOS
- Related Editorial
- Related Sponsors AI Security Playbook: Move Faster with AI, Without Compromising Security
- Related Sponsor Equal Experts helps organizations harness AI, modernize technology, and build better software through expert engineering, collaboration, and innovative delivery practices. Learn more .
The InfoQ Newsletter
A round-up of last week’s content on InfoQ sent out every Tuesday. Join a community of over 250,000 senior developers. View an example
We protect your privacy.