swiftzilla/skills

swift_testing

Swift Testing framework for unit tests, integration tests, and async testing with modern syntax.

First seen Jan 28, 2026

Installation

$ npx skills add swiftzilla/skills --skill swift_testing

Similar popular skills

Related neighbors and high-traction skills in the same topics — useful to compare before installing.

Also in this package

Other skills from swiftzilla/skills · top by installs.

npx skills add swiftzilla/skills

Browse all from swiftzilla/skills

More details

Agent compatibility

Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.

Claude Code Not declared
Cursor Not declared
Codex Not declared
GitHub Copilot Not declared
Windsurf Not declared
Gemini CLI Not declared
Cline Not declared
OpenCode Not declared

Repository health

Stars 7
License Proprietary
Default branch main
Open issues 1
Status Active

Skill metadata

Parsed from SKILL.md frontmatter.

Version1.0
LicenseProprietary
CompatibilitySwift 5.9+
More metadata
version
1.0
author
SwiftZilla
website
https://swiftzilla.dev

Package contents

Files included with this skill beyond the listing page.

  • skill md SKILL.md 3,058 B
  • docs SUMMARY.md 117 B

History

  1. First seen on skills.sh
  2. First recorded snapshot · 27 installs

SKILL.md

Swift Testing

This skill covers the modern Swift Testing framework introduced in Swift 5.9 for writing clean, expressive tests.

Overview

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.

Available References

  • [Test Basics](./references/test_basics.md) - Test declarations, assertions, and lifecycle
  • [Async Testing](./references/async_testing.md) - Testing async/await code
  • [Parameterized Tests](./references/parameterized_tests.md) - Running tests with multiple inputs
  • [Test Organization](./references/organization.md) - Suites, tags, and test structure

Quick Reference

Basic Test

import Testing

@Test
func addition() {
    let result = 1 + 1
    #expect(result == 2)
}

@Test
func throwsError() throws {
    #expect(throws: MyError.invalid) {
        try riskyOperation()
    }
}

Async Test

@Test
func fetchData() async throws {
    let data = try await fetchUser()
    #expect(data.name == "Ada")
}

Parameterized Test

@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)
}

Test Suite

@Suite
struct CalculatorTests {
    let calculator = Calculator()
    
    @Test
    func add() {
        #expect(calculator.add(2, 3) == 5)
    }
    
    @Test
    func subtract() {
        #expect(calculator.subtract(5, 3) == 2)
    }
}

Swift Testing vs XCTest

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

Best Practices

  1. Use descriptive names - Test names should explain behavior
  2. Test one thing - Each test should verify one concept
  3. Use #require for preconditions - Fail fast if setup fails
  4. Leverage parameterized tests - Test multiple inputs efficiently
  5. Organize with suites - Group related tests
  6. Use tags - Categorize tests for selective running
  7. Test async code - Use async test functions
  8. Keep tests independent - No shared state between tests

Running Tests

# 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

For More Information

Visit https://swiftzilla.dev for comprehensive Swift Testing documentation.