Files
Maksim Dimitrov 6792e91735 feat: add Swift language-specific rules
Add 5 rule files for Swift following the established pattern used by
TypeScript, Python, and Go rule sets. Covers Swift 6 strict concurrency,
Swift Testing framework, protocol-oriented patterns, Keychain-based
secret management, and SwiftFormat/SwiftLint hooks.
2026-02-17 15:43:14 +02:00

46 lines
1005 B
Markdown

---
paths:
- "**/*.swift"
- "**/Package.swift"
---
# Swift Testing
> This file extends [common/testing.md](../common/testing.md) with Swift specific content.
## Framework
Use **Swift Testing** (`import Testing`) for new tests. Use `@Test` and `#expect`:
```swift
@Test("User creation validates email")
func userCreationValidatesEmail() throws {
#expect(throws: ValidationError.invalidEmail) {
try User(email: "not-an-email")
}
}
```
## Test Isolation
Each test gets a fresh instance — set up in `init`, tear down in `deinit`. No shared mutable state between tests.
## Parameterized Tests
```swift
@Test("Validates formats", arguments: ["json", "xml", "csv"])
func validatesFormat(format: String) throws {
let parser = try Parser(format: format)
#expect(parser.isValid)
}
```
## Coverage
```bash
swift test --enable-code-coverage
```
## Reference
See skill: `swift-protocol-di-testing` for protocol-based dependency injection and mock patterns with Swift Testing.