Software Development

Depop Migrates 10,000 Unit Tests from XCTest to Swift Testing with AI-Orchestrated Workflow

The mobile development landscape is undergoing a significant shift as Apple pushes its modern testing framework, Swift Testing, to the forefront of the iOS ecosystem. At the fashion marketplace platform Depop, the engineering team has successfully completed a massive migration of approximately 10,000 unit tests from the legacy XCTest framework to the new Swift Testing paradigm. This ambitious project, led by engineer Anastasia Petrova, was designed not merely as a cosmetic update, but as a strategic effort to modernize infrastructure, enhance execution speed, and standardize testing conventions across a sprawling codebase. By leveraging a hybrid approach that combined automated SwiftSyntax-based conversion with intelligent AI orchestration, Depop achieved an 80% reduction in CI (Continuous Integration) runtime, setting a new benchmark for large-scale code migrations in the Swift community.

The Evolution of Apple’s Testing Framework

For over a decade, XCTest has been the default testing framework for Apple developers. While reliable and deeply integrated into Xcode, XCTest was built on the older Objective-C runtime, which often struggles to keep pace with the nuances of modern Swift development. Specifically, XCTest lacked native support for structured concurrency, resulting in verbose boilerplate code when testing asynchronous functions.

Swift Testing, introduced by Apple to address these architectural limitations, is built from the ground up to support modern Swift features. Its design philosophy centers on expressive, macro-driven syntax that allows developers to write tests that are more readable and easier to maintain. Key features include parameterized tests, which allow the same test logic to run against multiple inputs; nested suites, which provide hierarchical organization; and native integration with Swift Concurrency. For Depop, the primary motivation for the switch was the framework’s ability to leverage Swift’s cooperative thread pool, allowing tests to suspend and resume efficiently rather than blocking system threads.

The Migration Strategy: Automation vs. Human Oversight

The scale of the task—migrating 10,000 unit tests—presented a significant engineering challenge. A manual rewrite would have been prohibitively expensive in terms of developer time, while a purely AI-driven approach posed risks to code integrity. Petrova and her team opted for a pragmatic middle ground. They utilized "swift-testing-revolutionary," an open-source tool built on SwiftSyntax, to handle the heavy lifting of syntactic translation.

See also  I built an open-source AI coworker that logs in with 2FA without the model ever seeing your passwords

The decision to limit the role of AI in the code-transformation phase was deliberate. According to Petrova, early experiments revealed that AI agents, even when constrained by strict instructions, often attempted to refactor or rewrite the logic of the tests rather than performing a direct syntactic mapping. While this sometimes resulted in "cleaner" code, it introduced unpredictable variations that complicated the peer-review process. By enforcing a rule-based conversion through SwiftSyntax, the team ensured that the migration remained consistent and predictable, leaving the "intelligence" to the orchestration layer rather than the code generation itself.

The Role of AI in Orchestration

While the actual code transformation relied on deterministic scripts, AI agents were tasked with the logistics of the migration. The team built an automated pipeline that managed the lifecycle of each migration PR:

  1. Execution: The agent triggered the conversion script and ran the test suite across 100 iterations to ensure stability.
  2. Validation: If the tests passed without flakiness and no unexpected changes were detected in the codebase, the agent auto-approved the pull request.
  3. Remediation: In cases where tests failed, the agent attempted an initial fix, flagging the PR for human review only if the issue persisted.

This orchestration significantly reduced the "toil" associated with the migration, allowing engineers to focus on architectural hurdles rather than repetitive manual tasks.

Performance Gains and Technical Challenges

The most immediate and quantifiable impact of the migration was the dramatic improvement in CI performance. Because Swift Testing operates in-process on the cooperative thread pool, it is significantly more efficient than XCTest, which historically relied on separate processes or serial execution. On Depop’s small virtual machine runners, the team observed an 80% reduction in total execution time.

However, the transition was not without technical friction. The team encountered several recurring issues:

  • Data Races: In the transition from XCTest, some concurrency issues were exposed. These were resolved by isolating test instances or using the @Suite(.serialized) attribute to temporarily force serial execution while the team audited the code.
  • CI-Specific Failures: Certain UI tests, which performed well locally, failed on CI runners. The team traced this to thread-affinity issues, which were ultimately resolved by explicitly forcing UI-related tests to be @MainActor-isolated.
  • Refactoring Debt: The automated conversion could not automatically implement advanced Swift Testing features like parameterization or traits. Following the initial syntax migration, the team launched a secondary, manual phase to refactor tests to take full advantage of these advanced capabilities.
See also  Beyond the Box Score: Scottie Barnes and Victor Wembanyama in the 2026-27 NBA Season

Industry Comparisons and Broader Implications

The approach taken by Depop highlights a growing trend in software engineering: the use of "AI-assisted, syntax-first" migration. This contrasts with the strategy employed by other organizations, such as Sixt, which recently documented the migration of 7,000 unit tests using a more aggressive AI-centric approach. At Sixt, engineers developed a custom agent trained on 1,200 specific migration rules, completing their migration in a single afternoon at a cost of approximately $106.

The divergence between these two approaches illustrates the trade-offs in modern development. The Sixt approach prioritizes speed and scalability through heavily trained, specialized agents, while the Depop approach prioritizes auditability and long-term maintainability through deterministic, script-based tools.

The implications for the wider industry are clear: large-scale framework migrations, which were once considered daunting "death marches" for engineering teams, are becoming increasingly manageable through the strategic application of LLMs and automated syntax tooling. As Apple continues to deprecate legacy frameworks in favor of Swift-native technologies, the ability to automate these transitions will likely become a core competency for mobile engineering organizations.

Conclusion and Future Outlook

The success of the Depop migration serves as a case study for how legacy testing infrastructure can be modernized without sacrificing quality or developer productivity. By prioritizing a syntax-based transformation and utilizing AI as a high-level orchestrator rather than a primary code generator, the team avoided the pitfalls of "AI hallucination" while reaping the significant performance rewards of the Swift Testing framework.

Looking forward, the standardization of tests across the Depop codebase provides a foundation for more advanced testing practices, including property-based testing and enhanced integration testing, which were previously difficult to implement. As the mobile development community observes these migrations, the focus is likely to shift from whether to migrate to how to best orchestrate these transitions at scale. The Depop model offers a robust blueprint for teams looking to navigate this transition safely, efficiently, and effectively in an increasingly concurrent and performance-sensitive development environment.

This project reinforces the importance of "engineering hygiene." By treating the migration as a formal, automated, and strictly audited process, Depop has not only modernized its CI pipeline but has also established a scalable workflow for future technological shifts, ensuring that its testing infrastructure remains as agile as the products it builds.

Related Articles

Back to top button
Tech Newst
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.