{
  "id": 23109196,
  "title": "Lessons Learned from Migrating Unit Tests from XCTest to Swift Testing",
  "url": "https://urgent.news/2026/12/02/lessons-learned-from-migrating-unit-tests-from-xctest-to-swift-testing",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-12-02T11:00:00.000Z",
  "source": {
    "name": "InfoQ",
    "slug": "infoq",
    "url": "https://www.infoq.com/news/2026/12/xctest-swift-testing-migration/"
  },
  "original_language": null,
  "account": "Depop recently migrated around 10,000 unit tests from XCTest to Swift Testing, leveraging partial assistance from AI agents. The team decided to make this change for several reasons, including the belief that Swift Testing aligns with Apple's development direction, improved parallel execution capabilities, seamless integration with Swift Concurrency, and access to advanced features like parameterized tests, nested suites, and test traits. Additionally, the goal was to standardize Swift Testing usage across the codebase, as existing tests lacked an agreed-upon convention.\n\nA key advantage of the migration was test parallelization, which led to a significant reduction in execution time on the CI runner. Swift Testing runs tests in-process on Swift Concurrency's cooperative thread pool, allowing one test to suspend on await while another test uses the same thread. Early benchmarks indicated an approximately 80% improvement in runtime compared to XCTest with no parallelization.\n\nAI agents played a supportive role in the migration process, with a manual, syntax-based approach being the preferred method. The team opted against relying solely on AI due to potential issues such as subtle modifications that went beyond mechanical mapping, and the complexity it could introduce during the review process. However, the agents did facilitate the entire process, from running the conversion script and executing tests to opening a pull request (PR). If the PR passed all test executions across 100 repetitions without errors or flakiness, and no changes were made to the codebase, it was automatically approved. In case of test execution failures, the agent was tasked with fixing the tests, and the PR was flagged for human review.\n\nDespite the AI assistance, a few unexpected challenges emerged during the migration process. These included data races, tests passing locally but failing on CI, limitations of the conversion tool, and the additional overhead of PR review. Most data races were resolved by assigning each test its own instance or temporarily serializing tests using @Suite(.serialized). CI-only failures were primarily due to UI-related tests executing on secondary threads, which were addressed by forcing all UI-related tests to be @MainActor-isolated. Automatic conversion did not automatically incorporate advanced Swift Testing features like parameterized tests, nested suites, and test traits, necessitating separate manual refactoring efforts.\n\nWhile Depop utilized AI mainly as an orchestrator for the migration, other companies have experimented with greater AI involvement. For instance, Sixt engineer Ibrahim Oktay reported rewriting 7,000 unit tests using AI in just a single afternoon, costing only $106. Oktay highlighted the success of developing a custom conversion agent equipped with approximately 1,200 migration rules tailored to their app's architecture.",
  "summary": "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. By Sergio De Simone",
  "summary_source": "publisher",
  "key_points": [],
  "editors_take": null,
  "opinion": false,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "outlets_capped": false,
    "also_reported_by": []
  },
  "machine_translated": false,
  "ai_generated": true,
  "disclaimer": "Accounts, briefs, key points, the editor’s take and translations are written by software from other outlets’ reporting and may contain errors. A summary whose summary_source is \"publisher\" is the outlet’s own feed text. Always check the linked original."
}