askill
swift-testing

swift-testingSafety 90Repository

Standards for XCTest, Async Tests, and Test Organization

197 stars
3.9k downloads
Updated 2/2/2026

Package Files

Loading files...
SKILL.md

Swift Testing Standards

Priority: P0

Implementation Guidelines

XCTest Framework

  • Standard Naming: Prefix test methods with test (e.g., testUserLoginSuccessful).
  • Setup/Teardown: Use setUpWithError() and tearDownWithError() for environment management.
  • Assertions: Use specific assertions: XCTAssertEqual, XCTAssertNil, XCTAssertTrue, etc.

Async Testing

  • Async/Await: Mark test methods as async and use await directly inside them.
  • Expectations: Use XCTestExpectation for callback-based or delegate-based async logic.
  • Timeout: Always set reasonable timeouts for expectations to avoid hanging CI.

Test Organization

  • Unit Tests: Focus on logic isolation using mocks/stubs for dependencies.
  • UI Tests: Test user flows using XCUIApplication and accessibility identifiers.
  • Coverage: Aim for high coverage on critical business logic and state transitions.

Anti-Patterns

  • Thread Sleeps: **No Thread.sleep**: Use expectations or await.
  • Force Unwrapping in Tests: **No user!**: Use XCTUnwrap(user) for better failure messages.
  • Missing Assertions: **Tests must assert**: A test that only runs code is not a test.

References

Install

Download ZIP
Requires askill CLI v1.0+

AI Quality Score

92/100Analyzed 2/6/2026

A high-quality, comprehensive guide for Swift testing standards, covering XCTest, async patterns, and anti-patterns.

90
95
95
90
95

Metadata

Licenseunknown
Version-
Updated2/2/2026
PublisherHoangNguyen0403

Tags

ci-cdtesting