| name | swift-testing |
| description | > Use when this capability is needed. |
Swift Testing Expert (Project-Specific)
Testing expertise tailored for the iOS/macOS apps in this monorepo.
Project Test Structure
ProjectName/
├── ProjectName/ # Source files
├── ProjectNameTests/ # Unit tests
└── ProjectNameUITests/ # UI tests (if applicable)
Test Conventions
File Naming
- Test file:
[SourceFile]Tests.swift
- Example:
GameScene.swift → GameSceneTests.swift
Test Function Naming
func test_[unit]_[scenario]_[expectedResult]()
func test_scoreManager_addPoints_incrementsScore()
Standard Patterns
import XCTest
@testable import ProjectName
final class ComponentTests: XCTestCase {
var sut: Component!
override func setUp() {
super.setUp()
sut = Component()
}
override func tearDown() {
sut = nil
super.tearDown()
}
func test_method_condition_expectedResult() {
}
}
Async Testing
func test_asyncMethod_succeeds() async throws {
let result = try await sut.fetchData()
XCTAssertNotNil(result)
}
Memory Safety
Task { [weak self] in
guard let self else { return }
await self.performWork()
}
Running Tests
Cmd+U
xcodebuild test -scheme ProjectName -destination 'platform=iOS Simulator,name=iPhone 16'
Converted and distributed by TomeVault — claim your Tome and manage your conversions.