View in English

  • Apple Developer
    • 今すぐ始める

    「今すぐ始める」を詳しく見る

    • 概要
    • 学ぶ
    • Apple Developer Program

    最新情報

    • 最新ニュース
    • Hello Developer
    • プラットフォーム

    プラットフォームを詳しく見る

    • Appleプラットフォーム
    • iOS
    • iPadOS
    • macOS
    • tvOS
    • visionOS
    • watchOS
    • App Store

    特集

    • デザイン
    • 配信
    • ゲーム
    • アクセサリ
    • Web
    • Home
    • CarPlay
    • テクノロジー

    テクノロジーを詳しく見る

    • 概要
    • Xcode
    • Swift
    • SwiftUI

    特集

    • アクセシビリティ
    • App Intent
    • Apple Intelligence
    • ゲーム
    • 機械学習とAI
    • セキュリティ
    • Xcode Cloud
    • コミュニティ

    コミュニティを詳しく見る

    • 概要
    • 「Appleに相談」イベント
    • コミュニティによるイベント
    • デベロッパフォーラム
    • オープンソース

    特集

    • WWDC
    • Swift Student Challenge
    • デベロッパストーリー
    • App Store Awards
    • Apple Design Awards
    • Apple Developer Center
    • ドキュメント

    ドキュメントを詳しく見る

    • ドキュメントライブラリ
    • テクノロジー概要
    • サンプルコード
    • ヒューマンインターフェイスガイドライン
    • ビデオ

    リリースノート

    • 注目のアップデート
    • iOS
    • iPadOS
    • macOS
    • watchOS
    • visionOS
    • tvOS
    • Xcode
    • ダウンロード

    ダウンロードを詳しく見る

    • すべてのダウンロード
    • オペレーティングシステム
    • アプリ
    • デザインリソース

    特集

    • Xcode
    • TestFlight
    • フォント
    • SF Symbols
    • Icon Composer
    • サポート

    サポートを詳しく見る

    • 概要
    • ヘルプガイド
    • デベロッパフォーラム
    • フィードバックアシスタント
    • お問い合わせ

    特集

    • アカウントヘルプ
    • App Reviewガイドライン
    • App Store Connectヘルプ
    • 近日導入予定の要件
    • 契約およびガイドライン
    • システムステータス
  • クイックリンク

    • イベント
    • ニュース
    • Forum
    • サンプルコード
    • ビデオ
 

ビデオ

メニューを開く メニューを閉じる
  • コレクション
  • すべてのビデオ
  • 利用方法

その他のビデオ

  • 概要
  • Summary
  • コード
  • Swift Testingへの移行

    テストフレームワークの相互運用性を利用して、不安を感じることなくSwift Testingを導入し、XCTestと併用する方法を紹介します。開発を高速化しカバレッジを向上させる高度なテスト機能を段階的に導入するための、ベストプラクティスとパターンも学びます。

    関連する章

    • 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

    リソース

      • HDビデオ
      • SDビデオ

    関連ビデオ

    WWDC26

    • Swiftの新機能

    WWDC24

    • Swift Testingについて
    • Swift Testingの詳細
  • このビデオを検索
    • 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

  • ビデオ
  • WWDC26
  • Swift Testingへの移行
  • メニューを開く メニューを閉じる
    • iOS
    • iPadOS
    • macOS
    • tvOS
    • visionOS
    • watchOS
    Open Menu Close Menu
    • Swift
    • SwiftUI
    • Swift Playground
    • TestFlight
    • Xcode
    • Xcode Cloud
    • SF Symbols
    メニューを開く メニューを閉じる
    • アクセシビリティ
    • アクセサリ
    • Apple Intelligence
    • App Extension
    • App Store
    • オーディオとビデオ(英語)
    • 拡張現実
    • デザイン
    • 配信
    • 教育
    • フォント(英語)
    • ゲーム
    • ヘルスケアとフィットネス
    • アプリ内課金
    • ローカリゼーション
    • マップと位置情報
    • 機械学習とAI
    • オープンソース(英語)
    • セキュリティ
    • SafariとWeb(英語)
    メニューを開く メニューを閉じる
    • 英語ドキュメント(完全版)
    • 日本語ドキュメント(一部トピック)
    • チュートリアル
    • ダウンロード
    • フォーラム(英語)
    • ビデオ
    Open Menu Close Menu
    • サポートドキュメント
    • お問い合わせ
    • バグ報告
    • システム状況(英語)
    メニューを開く メニューを閉じる
    • Apple Developer
    • App Store Connect
    • Certificates, IDs, & Profiles(英語)
    • フィードバックアシスタント
    メニューを開く メニューを閉じる
    • 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 Research Device Program(英語)
    Open Menu Close Menu
    • Appleに相談
    • Apple Developer Center
    • App Store Awards(英語)
    • Apple Design Awards
    • Apple Developer Academy(英語)
    • WWDC
    最新ニュースを読む。
    Apple Developerアプリを入手する。
    Copyright © 2026 Apple Inc. All rights reserved.
    利用規約 プライバシーポリシー 契約とガイドライン