22.2 · XCTest and Swift Testing

Apple now ships two test frameworks side by side. You are expected to read XCTest fluently, write new unit tests in Swift Testing, and know what each one cannot do.

Mental model. XCTest is class-based and covers everything (UI and performance too); Swift Testing is macro-based, parallel by default and for unit-level tests. They can live in the same target.

Two frameworks

What changed with @Test, #expect and #require, and what stays in XCTest.

  1. How do XCTest and Swift Testing differ, and when do you still use XCTest? 22.2.1 · L3
    XCTest is the long-standing, Objective-C-rooted framework: you subclass XCTestCase, name methods test…, use setUpWithError and tearDown, and assert with…

More in Testing