skills/swift_testing/SKILL.md
Swift Testing framework for unit tests, integration tests, and async testing with modern syntax.
npx skillsauth add swiftzilla/skills swift_testingInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
This skill covers the modern Swift Testing framework introduced in Swift 5.9 for writing clean, expressive tests.
Swift Testing is Apple's modern testing framework that provides a more expressive and flexible way to write tests compared to XCTest. It features Swift-native syntax, parameterized tests, and better async support.
import Testing
@Test
func addition() {
let result = 1 + 1
#expect(result == 2)
}
@Test
func throwsError() throws {
#expect(throws: MyError.invalid) {
try riskyOperation()
}
}
@Test
func fetchData() async throws {
let data = try await fetchUser()
#expect(data.name == "Ada")
}
@Test(arguments: ["hello", "world", "swift"])
func stringLength(string: String) {
#expect(string.count > 0)
}
@Test(arguments: zip([1, 2, 3], [1, 4, 9]))
func squared(input: Int, expected: Int) {
#expect(input * input == expected)
}
@Suite
struct CalculatorTests {
let calculator = Calculator()
@Test
func add() {
#expect(calculator.add(2, 3) == 5)
}
@Test
func subtract() {
#expect(calculator.subtract(5, 3) == 2)
}
}
| Feature | Swift Testing | XCTest | |---------|--------------|---------| | Syntax | Native Swift | Objective-C heritage | | Async | First-class | Added later | | Parameters | Built-in | Manual loops | | Assertions | #expect, #require | XCTAssert | | Suite | @Suite | Class-based |
# Run all tests
swift test
# Run specific test
swift test --filter addition
# Run tests by tag
swift test --tag unit
# Run with verbose output
swift test --verbose
Visit https://swiftzilla.dev for comprehensive Swift Testing documentation.
tools
Use this skill when you need expert Swift/iOS architectural guidance, semantic codebase analysis, or PR impact reviews. It provides a senior mentor layer for Swift (SwiftUI, UIKit, Combine, Concurrency) and a semantic engine to query local code context. Trigger this skill to: 1. Validate architectural patterns before implementation using 'ask'. 2. Find and map local code dependencies using 'context'. 3. Analyze the risk and blast radius of a PR using 'review'. 4. Generate system overviews for onboarding using 'onboard'. 5. Troubleshoot runtime crashes with semantic LLDB tools using 'debug'. Activate even if specific keywords are missing but the intent is improving Swift code quality or understanding project structure.
development
SwiftUI framework concepts including property wrappers, state management, and reactive UI patterns.
development
Swift style guidelines covering naming conventions, code organization, and best practices for writing idiomatic Swift code.
tools
Swift language structures including collections, optionals, closures, generics, control flow, and core language features.