/swift:testingfrom swift
Use when writing, running, or debugging Swift tests, covering Swift Testing traits, expectations, arguments, exit tests, attachments, generated inputs, privacy grants, XCTest performance metrics, and CI
Ships in swift. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Covers package and Xcode test targets xcodebuild test runs, with Swift Testing as runner and XCTest for measurement alone. Use code:test for test design: oracles, cases, structure, independence, doubles, generated-input kinds, and grading.
Tests use each module below before a hand form:
| [INDEX] | [FIELD] | [MODULES] |
|---|---|---|
| [01] | Runner, expectations, attachments | Testing, with AppKit, CoreGraphics, CoreImage, Foundation overlays |
| [02] | Structured comparison | CustomDump (expectNoDifference) |
| [03] | Generated inputs | PropertyBased |
| [04] | Controlled time | Clocks (ImmediateClock, TestClock) |
| [05] | Issues library code reports | IssueReportingTestSupport |
| [06] | Measurement | XCTest metrics |
[REFERENCES]:
PropertyBasedxcodebuild test -workspace <workspace> -scheme <scheme> runs the scheme's default test plan, which lists every functional test target:
xctest agent of the selected Xcode, and Swift Testing runs a bundle's tests in parallel-only-testing:<id> and -skip-testing:<id> run or exclude a target, suite, or test (-only-testing:<target>/<suite>/<test>())IssueReportingTestSupport make expectNoDifference and reportIssue record Swift Testing issuesTraits state a test's conditions on its declaration:
| [INDEX] | [TRAIT] | [USE] |
|---|---|---|
| [01] | .timeLimit(.minutes(<n>)) | Hang guard on a suite waiting for a process or stream |
| [02] | .serialized | Suite whose tests share process-wide or window server state |
| [03] | .enabled(if:), .disabled(if:) | Fact a correct run on a supported Mac lacks |
| [04] | .bug(<url>, id: <id>) | Issue tracking behavior a withKnownIssue body asserts |
| [05] | TestScoping conformance | State each test scopes through a task local |
| [06] | .compactMapIssues, .filterIssues | Context added to an issue, never a failure dropped |
TimeLimitTrait.Duration marks .seconds and finer units unavailable, and a test past its limit records timeLimitExceeded.serialized orders its suite's tests and nested suites, while separate suites run beside itEach fact takes the expectation that states it:
| [INDEX] | [FACT] | [FORM] |
|---|---|---|
| [01] | Fact later steps need | try #require(<condition>), try #require(<optional>) |
| [02] | Fact checked, test continuing | #expect(<condition>, <comment>) |
| [03] | Structured value | expectNoDifference(<got>, <want>) |
| [04] | Failure of a type | #expect(throws: <Error>.self) { ... } returning E? |
| [05] | Failure equal to a value | #expect(throws: <error>) { ... } over Equatable error |
| [06] | No failure | #expect(throws: Never.self) { ... } |
| [07] | Process exit | #expect(processExitsWith: <condition>) { ... } |
| [08] | Cause caught outside an expectation | Issue.record(<error>) |
| [09] | Behavior known to be wrong | withKnownIssue { ... } under .bug(...) |
#expect(throws:) returns, as its performing:throws: matcher overloads are deprecated in favor of that result#expect prints the operands of a comparison it holds, and a Bool bound beforehand prints its name alone, so its Comment interpolates every value a reader needs#require exceed the scopes -warn-long-expression-type-checking-scopes <n> allows under warnings as errors, so tests pass a bound Bool and CommentwithKnownIssue passes while its body records an issue and records knownIssueNotRecorded once the behavior is fixed, with isIntermittent left falseTest.cancel(_:) and Issue.record(_:severity: .warning) end or mark a test with no failing verdict@Test(arguments:) runs one case per element and reports each case alone:
zip(<first>, <second>) pairs elementsSendable, held in file-scope private let tables with each partition written outEncodable, CustomTestArgumentEncodable, or Identifiable or RawRepresentable over EncodableAsync tests await each event they assert and observe absence by ending its source:
confirmation(_:expectedCount:) takes an Int, a range, or 0, and counts confirmations before its body returns, so the body awaits a later callbackAsyncStream.makeStream() continuations a double yields to, finished after the act and reduced, so a count of zero is exactsome Clock<Duration>: ImmediateClock returns each sleep at once and advances now, TestClock moves through advance(by:)ImmediateClock<Duration>.Instant(offset: .seconds(5))Suites launch no application, write no application bundle, change no session or window server state, and read no other process. Suites of file and process code can write inside a temporary folder they remove, or start and end a child process of their own. Tests own what they create, under a name no other test uses, and release it when their scope ends:
@Suite(.timeLimit(.minutes(1)))
final class ArchiveTests {
let folder = FileManager.default.temporaryDirectory.appending(component: UUID().uuidString).resolvingSymlinksInPath()
init() throws { try FileManager.default.createDirectory(at: folder, withIntermediateDirectories: true) }
deinit {
do { try FileManager.default.removeItem(at: folder) } catch { Issue.record(error) }
}
}
ArchiveTests holds this shape over the folder its tests write into:
deinit removes it once the test endsIssue.record in place of try?UUID folder under temporaryDirectory, or .itemReplacementDirectory@testable import constructs internal inputs (records decoded from JSON rows), and assertions read members callers use#expect(processExitsWith:observing:) runs its body in a child process of the test runner, for paths that end a process (precondition, fatalError, exit):
.success, .failure, .exitCode(<code>), and .signal(<signal>)observing: [\.standardOutputContent, \.standardErrorContent] keeps output in the ExitTest.Result the macro returns, empty otherwiseCodable and SendableAttachment.record(<value>, named:) adds a value to a test's results, which xcodebuild writes into the result bundle:
Data, String, and [UInt8] record as their bytes, an Encodable type declaring Attachable as JSON through the Foundation overlayAttachment(contentsOf: <url>) reads a file the test wroteCGImage, NSImage, and CIImage record with as: .png, .jpeg(withEncodingQuality:), or AttachableImageFormat(contentType:)What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub bsamiee/rasm --plugin swift3 skills in this plugin
/codingUse when writing or reviewing Swift, covering functional design with typed throws, value types, and structured concurrency/debuggingUse when Swift code misbehaves at runtime and its cause is unproven (failing or crashing test, trap, thrown error, hung task, data race, executor violation, leak), covering Swift sessions of the debugger server, test runners, error and failure stops, sanitizers, backtraces, and dSYMsOther plugins' skills for the same job