View in English

  • Apple Developer
    • Get Started

    Explore Get Started

    • Overview
    • Learn
    • Apple Developer Program

    Stay Updated

    • Latest News
    • Hello Developer
    • Platforms

    Explore Platforms

    • Apple Platforms
    • iOS
    • iPadOS
    • macOS
    • tvOS
    • visionOS
    • watchOS
    • App Store

    Featured

    • Design
    • Distribution
    • Games
    • Accessories
    • Web
    • Home
    • CarPlay
    • Technologies

    Explore Technologies

    • Overview
    • Xcode
    • Swift
    • SwiftUI

    Featured

    • Accessibility
    • App Intents
    • Apple Intelligence
    • Games
    • Machine Learning & AI
    • Security
    • Xcode Cloud
    • Community

    Explore Community

    • Overview
    • Meet with Apple events
    • Community-driven events
    • Developer Forums
    • Open Source

    Featured

    • WWDC
    • Swift Student Challenge
    • Developer Stories
    • App Store Awards
    • Apple Design Awards
    • Apple Developer Centers
    • Documentation

    Explore Documentation

    • Documentation Library
    • Technology Overviews
    • Sample Code
    • Human Interface Guidelines
    • Videos

    Release Notes

    • Featured Updates
    • iOS
    • iPadOS
    • macOS
    • watchOS
    • visionOS
    • tvOS
    • Xcode
    • Downloads

    Explore Downloads

    • All Downloads
    • Operating Systems
    • Applications
    • Design Resources

    Featured

    • Xcode
    • TestFlight
    • Fonts
    • SF Symbols
    • Icon Composer
    • Support

    Explore Support

    • Overview
    • Help Guides
    • Developer Forums
    • Feedback Assistant
    • Contact Us

    Featured

    • Account Help
    • App Review Guidelines
    • App Store Connect Help
    • Upcoming Requirements
    • Agreements and Guidelines
    • System Status
  • Quick Links

    • Events
    • News
    • Forums
    • Sample Code
    • Videos
 

Videos

Open Menu Close Menu
  • Collections
  • All Videos
  • About

More Videos

  • About
  • Summary
  • Code
  • Migrate to Swift Testing

    Learn how to fearlessly adopt Swift Testing alongside your XCTests using test framework interoperability. Discover best practices and patterns for incrementally introducing advanced testing features that accelerate development and increase coverage.

    Chapters

    • 0:07 - Introduction
    • 1:08 - Swift Testing basics
    • 2:50 - Migration strategy
    • 5:48 - Test framework interoperability
    • 7:43 - Interoperability modes
    • 13:02 - Common migration patterns
    • 15:34 - Parameterized tests
    • 18:02 - Exit tests
    • 20:04 - Next steps

    Resources

      • HD Video
      • SD Video

    Related Videos

    WWDC26

    • What’s new in Swift

    WWDC24

    • Go further with Swift Testing
    • Meet Swift Testing
  • Search this video…
    • 1:12 - Name a test using a raw identifier

      import Testing
      
      @testable import DemoApp
      
      @Test func `Default climate: tropical`() async throws {
          let fruit = Fruit(name: "Coconut")
          #expect(fruit.climate == .tropical)
      }
    • 5:03 - Wrap XCTFail in a test helper function

      func testUniqueFruitNames() async throws {
          assertUnique(Market.fruits + [Fruit.lychee])
      }
      
      // TestHelpers.swift
      
      func assertUnique(_ fruits: [Fruit], file: StaticString = #filePath, line: UInt = #line) {
          var uniqueNames = Set<String>()
          for name in fruits.map(\.name) {
              if !uniqueNames.insert(name).inserted {
                  XCTFail("Duplicate name: \(name)", file: file, line: line)
              }
          }
      }
    • 10:12 - Replace XCTFail with Issue.record in the test helper

      import Testing
      
      func assertUnique(_ fruits: [Fruit], sourceLocation: SourceLocation = ...) {
          var uniqueNames = Set<String>()
          for name in fruits.map(\.name) {
              if !uniqueNames.insert(name).inserted {
                  Issue.record("Duplicate name: \(name)", sourceLocation: sourceLocation)
              }
          }
      }
    • 12:15 - Run Swift Package tests with the strict interoperability mode from Terminal

      > SWIFT_TESTING_XCTEST_INTEROP_MODE=strict swift test
    • 13:10 - Common migration: skipping tests

      let isFall = false
      
      // XCTest
      func testSwallowFallMigration() async throws {
          try XCTSkipIf(!isFall, "Wrong season for migration")
          // ...
      }
      
      // Test.cancel interoperability from Swift Testing
      func testSwallowFallMigration() async throws {
          if !isFall {
              try Test.cancel("Wrong season for migration")
          }
          // ...
      }
      
      // ✅ Prefer test trait in Swift Testing
      @Test(.enabled(if: isFall, "Wrong season for migration"))
      func `Swallow fall migration`() async throws {
         // ...
      }
    • 13:41 - Common migration: halting after test failures

      func testExample() async throws {
          #expect(Fruit.banana.climate == .temperate)
      
          try #require(Fruit.banana == Fruit.plantain)
          XCTFail("This is never reached")
      }
    • 15:57 - Example of nested loops which can be converted into a parameterized @Test function

      struct BirdTests {
      
          @Test func `Birds flap wings successfully`() async throws {
              for bird in Aviary.birds {
                  for count in (40...100) {
                      try await bird.flapWings(count: count)
                  }
              }
          }
      
      }
    • 16:47 - Refactor nested loops into a parameterized @Test function

      struct BirdTests {
      
          @Test(arguments: Aviary.birds, 40...100)
          func `Birds flap wings successfully`(bird: Bird, count: Int) async throws {
              try await bird.flapWings(count: count)
          }
      
      }
    • 18:21 - Precondition check on empty input name in an initializer

      // In `Bird.init(...)`
      if name.isEmpty {
          preconditionFailure("Bird name cannot be empty")
      }
    • 19:27 - Add coverage for precondition failure with exit test

      extension BirdTests {
      
          @Test func `Bird with empty name crashes`() async throws {
              await #expect(processExitsWith: .failure) {
                  _ = Bird(name: "")
              }
          }
      
      }
    • 0:07 - Introduction
    • How to fearlessly migrate from XCTest to Swift Testing using the new interoperability feature.

    • 1:08 - Swift Testing basics
    • A quick review of core Swift Testing building blocks — the @Test macro, #expect, and how they compare to XCTest assertions.

    • 2:50 - Migration strategy
    • Covers the recommended incremental approach: leave existing XCTests in place, and start writing new tests in Swift Testing right away.

    • 5:48 - Test framework interoperability
    • Introduces the interoperability feature that lets you safely call XCTest or Swift Testing API from within a test belonging to the other framework.

    • 7:43 - Interoperability modes
    • Walks through the four interoperability modes — Limited, Complete, Strict, and None — and how to configure them in Xcode Test Plans and Swift packages.

    • 13:02 - Common migration patterns
    • Covers practical patterns you will encounter during migration, including replacing XCTSkip with Test.cancel or traits, and continueAfterFailure with #require.

    • 15:34 - Parameterized tests
    • Shows how to replace loop-based XCTest cases with Swift Testing parameterized tests for faster parallel execution and clearer failure reporting.

    • 18:02 - Exit tests
    • Demonstrates how to use Swift Testing exit tests to cover code paths that call preconditionFailure or crash, running them safely in a child process.

    • 20:04 - Next steps
    • Recaps the migration path, highlights Swift Testing open-source availability and cross-platform support, and encourages community participation.

Developer Footer

  • Videos
  • WWDC26
  • Migrate to Swift Testing
  • Open Menu Close Menu
    • iOS
    • iPadOS
    • macOS
    • tvOS
    • visionOS
    • watchOS
    • App Store
    Open Menu Close Menu
    • Swift
    • SwiftUI
    • Swift Playground
    • TestFlight
    • Xcode
    • Xcode Cloud
    • Icon Composer
    • SF Symbols
    Open Menu Close Menu
    • Accessibility
    • Accessories
    • Apple Intelligence
    • Audio & Video
    • Augmented Reality
    • Business
    • Design
    • Distribution
    • Education
    • Games
    • Health & Fitness
    • In-App Purchase
    • Localization
    • Maps & Location
    • Machine Learning & AI
    • Security
    • Safari & Web
    Open Menu Close Menu
    • Documentation
    • Downloads
    • Sample Code
    • Videos
    Open Menu Close Menu
    • Help Guides & Articles
    • Contact Us
    • Forums
    • Feedback & Bug Reporting
    • System Status
    Open Menu Close Menu
    • Apple Developer
    • App Store Connect
    • Certificates, IDs, & Profiles
    • Feedback Assistant
    Open Menu Close Menu
    • Apple Developer Program
    • Apple Developer Enterprise Program
    • App Store Small Business Program
    • MFi Program
    • Mini Apps Partner Program
    • News Partner Program
    • Video Partner Program
    • Security Bounty Program
    • Security Research Device Program
    Open Menu Close Menu
    • Meet with Apple
    • Apple Developer Centers
    • App Store Awards
    • Apple Design Awards
    • Apple Developer Academies
    • WWDC
    Read the latest news.
    Get the Apple Developer app.
    Copyright © 2026 Apple Inc. All rights reserved.
    Terms of Use Privacy Policy Agreements and Guidelines