swift-testing
Expertise for writing XCTest tests for Swift/SwiftUI iOS and macOS apps in this project. Use when writing tests for HabitQuest, AvoidObstaclesGame, CodingReviewer, MomentumFinance, PlannerApp, or Shared-Kit. Follows project conventions and patterns.
Installation
Suivez les instructions du dépôt pour votre agent. Consultez les fichiers et dépendances avant l’installation.
Voir la source ↗GuidesInstructions
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]()
// Example:
func test_scoreManager_addPoints_incrementsScore()
Standard Patterns
import XCTest
@testable import ProjectName
final class ComponentTests: XCTestCase {
var sut: Component! // System Under Test
override func setUp() {
super.setUp()
sut = Component()
}
override func tearDown() {
sut = nil
super.tearDown()
}
func test_method_condition_expectedResult() {
// Arrange
// Act
// Assert
}
}
Async Testing
func test_asyncMethod_succeeds() async throws {
let result = try await sut.fetchData()
XCTAssertNotNil(result)
}
Memory Safety
// Use [weak self] in closures
Task { [weak self] in
guard let self else { return }
await self.performWork()
}
Running Tests
# Via Xcode
Cmd+U # Run all tests
# Via command line
xcodebuild test -scheme ProjectName -destination 'platform=iOS Simulator,name=iPhone 16'
Exemples
Consultez les exemples du dépôt source.
Voir la source ↗Historique source
- Date d’indexation
- 2026-01-20
- Mise à jour de l’index
- 2026-03-04
- Branch
- main
Les dates concernent ce répertoire. Consultez le dépôt pour l’historique du code.
GitHub ↗chat Comments (0)
Sign in to join the discussion and leave a comment.
No comments yet. Be the first to share your thoughts!