Agent skill
Swift Testing
Standards for XCTest, Async Tests, and Test Organization
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/testing-hoangnguyen0403-agent-skills-standar-3
Metadata
Additional technical details for this skill
- labels
-
swift testing xctest async-testing
- triggers
-
{ "files": [ "**/*Tests.swift" ], "keywords": [ "XCTestCase", "XCTestExpectation", "XCTAssert" ] }
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()andtearDownWithError()for environment management. - Assertions: Use specific assertions:
XCTAssertEqual,XCTAssertNil,XCTAssertTrue, etc.
Async Testing
- Async/Await: Mark test methods as
asyncand useawaitdirectly inside them. - Expectations: Use
XCTestExpectationfor 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
XCUIApplicationand 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
- XCTest Patterns & Async Tests
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?