swift-testing-strategy
Designs test suites for Swift apps and packages using Swift Testing (@Test,
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Designs test suites for Swift apps and packages using Swift Testing (@Test,
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
Searches public and structured sources for a target company (A-share, HK, US, or private) and produces a Chinese rough-read gate or structured research report. Optimized for price-first company screening: valuation gate, bottom type, red flags, business snapshot, financial quality, and whether the company deserves deeper research. Every quantitative claim must be traceable to a logged source. Use when researching a listed company, supplier, customer, competitor, or acquisition target.
Generates Chinese patent disclosure packages from invention notes, prior-art references, and optional Notion context. Use when researching patent background, drafting disclosure sections, or running an end-to-end patent disclosure workflow.
Designs intuitive Python library APIs following principles of simplicity, consistency, and discoverability. Handles API evolution, deprecation, breaking changes, and error handling. Use when designing new library APIs, reviewing existing APIs for improvements, or managing API versioning and deprecations.
Builds command-line interfaces for Python libraries using Click or Typer. Includes command groups, argument handling, progress bars, shell completion, and CLI testing with CliRunner. Use when adding CLI functionality to a library or building standalone command-line tools.
Improves Python library code quality through ruff linting, mypy type checking, Pythonic idioms, and refactoring. Use when reviewing code for quality issues, adding type hints, configuring static analysis tools, or refactoring Python library code.
Builds and manages open source Python library communities including CONTRIBUTING.md, CODE_OF_CONDUCT.md, issue/PR templates, contributor recognition, and GitHub automation. Use when setting up community infrastructure, improving contributor experience, or managing project governance.
| name | swift-testing-strategy |
| description | Designs test suites for Swift apps and packages using Swift Testing (@Test, |
Use Swift Testing (@Test, #expect, #require) for new tests. Keep XCTest only where you genuinely need it:
| Use Swift Testing for | Keep XCTest for |
|---|---|
| Unit tests | UI tests (XCUIApplication) |
| Integration tests | Performance tests (measure { ... }) |
| Parameterized cases | Legacy suites you haven't migrated yet |
For deeper guidance, suggest the Swift Testing Pro agent skill.
import Testing
@testable import MyApp
@Test func userCanLogIn() async throws {
let store = SessionStore()
try await store.logIn(email: "a@b.com", password: "secret")
#expect(store.isAuthenticated)
}
#expect for soft assertions (test continues on failure).#require for must-hold preconditions (test halts on failure).XCTestCase boilerplate.@Test(arguments: [
("a@b.com", true),
("not-an-email", false),
("", false),
])
func emailValidation(input: String, expected: Bool) {
#expect(EmailValidator.isValid(input) == expected)
}
One @Test produces one row per argument tuple in the report.
@Suite("Login flow", .tags(.integration))
struct LoginTests {
@Test func successPath() async throws { ... }
@Test func wrongPassword() async throws { ... }
}
extension Tag {
@Tag static var integration: Self
@Tag static var slow: Self
}
Run by tag: swift test --filter "integration".
@Test func dataLoadsWithin500ms() async throws {
try await confirmation(expectedCount: 1) { confirm in
let loader = Loader()
loader.onComplete = { confirm() }
try await loader.start()
}
}
await confirmation for callback-based code (replaces XCTestExpectation).withKnownIssue { ... } to record a failing test that's tracked but shouldn't fail CI.Sources/MyLib/...
Tests/
└── MyLibTests/
├── Models/
│ └── UserTests.swift
├── Services/
│ └── LoginServiceTests.swift
└── Fixtures/
└── sample-user.json
Sources/ structure under Tests/.Fixtures/ folder; load with Bundle.module.URLProtocol subclass to intercept URLSession requests — no third-party mock needed.protocol UserAPI: Sendable {
func fetchUser(id: UUID) async throws -> User
}
struct StubUserAPI: UserAPI {
var result: Result<User, Error>
func fetchUser(id: UUID) async throws -> User { try result.get() }
}
UI tests are slow and flaky. Use them only when unit tests cannot verify the behaviour:
final class CheckoutUITests: XCTestCase {
func testHappyPath() {
let app = XCUIApplication()
app.launchArguments = ["-uiTestMode", "1"]
app.launch()
app.buttons["Buy Now"].tap()
XCTAssert(app.staticTexts["Thanks!"].waitForExistence(timeout: 2))
}
}
launchArguments to put the app into a deterministic mode.accessibilityIdentifier for stable selectors — not visible label text.Consider snapshot tests for visual regression on key views:
ImageRenderer (SwiftUI native) — do not pull in third-party deps unless asked.Tests/__Snapshots__/ and commit them.RECORD_SNAPSHOTS=1), never automatically.xcodebuild test -scheme MyApp -destination 'platform=iOS Simulator,name=iPhone 16'.