> swift-testing
Standards for XCTest, Async Tests, and Test Organization. Use when writing XCTest cases, async tests, or organizing test suites in Swift. (triggers: **/*Tests.swift, XCTestCase, XCTestExpectation, XCTAssert)
curl "https://skillshub.wtf/HoangNguyen0403/agent-skills-standard/swift-testing?format=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
> related_skills --same-repo
> typescript-tooling
Development tools, linting, and build config for TypeScript. Use when configuring ESLint, Prettier, Jest, Vitest, tsconfig, or any TS build tooling. (triggers: tsconfig.json, .eslintrc.*, jest.config.*, package.json, eslint, prettier, jest, vitest, build, compile, lint)
> typescript-security
Secure coding practices for TypeScript. Use when validating input, handling auth tokens, sanitizing data, or managing secrets and sensitive configuration. (triggers: **/*.ts, **/*.tsx, validate, sanitize, xss, injection, auth, password, secret, token)
> typescript-language
Modern TypeScript standards for type safety and maintainability. Use when working with types, interfaces, generics, enums, unions, or tsconfig settings. (triggers: **/*.ts, **/*.tsx, tsconfig.json, type, interface, generic, enum, union, intersection, readonly, const, namespace)
> typescript-best-practices
Idiomatic TypeScript patterns for clean, maintainable code. Use when writing or refactoring TypeScript classes, functions, modules, or async logic. (triggers: **/*.ts, **/*.tsx, class, function, module, import, export, async, promise)