搜索

PythonReactSEOPDF
GitHub Skill

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.

dboone323☆ 1 仓库 Stars0 仓库 Forks

安装与使用

请根据来源仓库和你的 AI 工具说明安装此技能。先阅读技能文件和依赖要求,再添加到工作流。

查看来源 ↗使用指南

技能说明

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'

使用示例

查看来源仓库中的使用示例与配置说明。

查看来源 ↗

来源历史

收录时间
2026-01-20
索引更新时间
2026-03-04
Branch
main

收录与同步日期属于本站记录。源码修改历史请查看来源仓库。

GitHub ↗

chat Comments (0)

chat_bubble_outline

No comments yet. Be the first to share your thoughts!