AgentStack
Browse Sign in
Browse Why AgentStack Sell Docs
Sign in
SKILL verified MIT Self-run

Swift Testing

skill-mintuz-skills-swift-testing · by mintuz

WHEN writing tests in Swift with the Swift Testing framework; NOT XCTest.

No reviews yet
0 installs
40 views
0.0% view→install

Install

$ agentstack add skill-mintuz-skills-swift-testing

✓ scanned · ✓ verified, works with Claude Code, Cursor, and more.

Security review

✓ Passed

No issues found. Passed automated security review. · v0.1.0 How review works →

  • Prompt-injection patterns
  • Secret / credential exfiltration
  • Dangerous shell & filesystem operations
  • Untrusted network calls
  • Known-malicious package signatures

What it can access

  • Network access No
  • Filesystem access No
  • Shell / process execution No
  • Environment & secrets No
  • Dynamic code execution No

From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.

View the full security report →

Verified badge

Passed review? Show it. Paste this badge into your README, it links to the public security report.

AgentStack Verified badge Links to your public security report.
[![AgentStack Verified](https://agentstack.voostack.com/badges/verified.svg)](https://agentstack.voostack.com/security/report/skill-mintuz-skills-swift-testing)

Reliability & compatibility

Security review passed
0 installs to date
no reviews yet
7mo ago

Declared compatibility

Claude CodeClaude Desktop

Compatibility is declared by the source manifest. End-to-end runtime verification is coming, see below.

Preview Execution monitoring

We're building live execution health for every listing: tool-call success rate, median latency, uptime, and last-checked timestamps, measured, not self-reported. It isn't live yet, so we don't show numbers we can't stand behind.

How agent discovery & health will work →
Are you the author of Swift Testing? Claim this listing to set pricing, connect Stripe payouts, and keep 70% of every sale.
Sign up to claim

About

Swift Testing Framework: Basics

Guidance for starting with Swift Testing (Testing framework) and writing clear, macro-driven tests.

Core Concepts

  • Import Testing to unlock macros; tests are plain functions annotated with @Test.
  • Name tests freely; use @Test("Display Name") to set the navigator title.
  • #expect is the primary assertion; pass a boolean expression to assert truthy outcomes.
  • Async/throwing tests are supported via async/throws on the test function.
  • Works alongside XCTest in the same project.

Example: Simple Test

import Testing

func add(_ a: Int, _ b: Int) -> Int { a + b }

@Test("Verify addition function") func verifyAdd() {
    let result = add(1, 2)
    #expect(result == 3)
}

Expecting Throws

Use #expect(throws:) to verify a thrown error. Inspect the error via the closure overload when you need to assert the specific case.

@Test func verifyThrowingFunction() {
    #expect(throws: MyError.self) {
        try throwingFunction()
    }

    #expect {
        try throwingFunction()
    } throws: { error in
        guard let myError = error as? MyError else { return false }
        return myError == .invalidInput
    }
}

Require vs Expect

  • #require throws immediately when the condition is false, halting the test early.
  • Handy for unwrapping optionals before continuing with more assertions.
@Test func verifyOptionalFunc() throws {
    let result = try #require(optionalFunc()) // unwrap or fail fast
    #expect(result > 0)
}

Recording Issues

Use Issue.record("message") to log and exit gracefully when continuing the test is pointless.

@Test func verifyOptionalFunc() throws {
    guard let result = optionalFunc() else {
        Issue.record("optional result is nil")
        return
    }
    #expect(result > 0)
}

Best Practices Checklist

  • [ ] Prefer @Test-annotated free functions; no need for XCTest naming conventions.
  • [ ] Use @Test("Name") to keep navigator titles readable.
  • [ ] Default to #expect for assertions; add multiple expects per test when logical.
  • [ ] Use #require to guard preconditions/unwrap optionals before further checks.
  • [ ] Assert thrown errors with #expect(throws:), including specific case checks.
  • [ ] Mix Swift Testing with XCTest during migration; convert incrementally.
  • [ ] Keep tests small and focused; one behavior per test function.

Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

Install and usage instructions live in the source repository linked above.

Reviews

No reviews yet, be the first.

Versions

  • v0.1.0 Imported from the upstream source.