swift-testing
Installation
SKILL.md
Swift Testing Framework: Basics
Guidance for starting with Swift Testing (Testing framework) and writing clear, macro-driven tests.
Core Concepts
- Import
Testingto unlock macros; tests are plain functions annotated with@Test. - Name tests freely; XCTest's
testname prefix has no meaning in Swift Testing. Use@Test("Display Name")to set the navigator title. #expectis the primary assertion; pass a boolean expression to assert truthy outcomes.- Assert one behaviour per test function. Split a test that checks unrelated behaviours.
- Async/throwing tests are supported via
async/throwson the test function. - Swift Testing and XCTest run side by side in the same test target. A project that still holds XCTest tests is a supported end state.
- Convert an existing XCTest target in stages when one change would be too large to review or to bisect. Give the staged order, one class or small batch per stage. Keep the target green between stages.
- Swift Testing covers unit and integration tests. It provides no UI-automation API and no performance-measurement API. Keep XCUITest tests and XCTest
measureperformance tests on XCTest.
Example: Simple Test
import Testing