swift-testing-guidelines

Guide Swift StateTree tests using @Test, #expect, and Issue.record.

1|Updated Nov 22, 2025
One-click install
npx skills add https://github.com/gmliao/swift-state-tree --skill swift-testing-guidelines
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: swift-testing-guidelines
Source: https://github.com/gmliao/swift-state-tree/tree/main/.agent/skills/SwiftStateTree/swift-testing-guidelines
Command: npx skills add https://github.com/gmliao/swift-state-tree --skill swift-testing-guidelines

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill provides a structured set of guidelines to write correct and maintainable tests for Swift StateTree using the Swift Testing framework. It helps teams avoid common pitfalls and align test style across modules.

Core Features & Use Cases

  • Clear guidance on using @Test, #expect, and Issue.record for tests.
  • Examples illustrating common test patterns: basic tests, setup/teardown, assertions, and async tests.
  • Coverage across core modules: core library, transport, macros, matchmaking, and more.

Quick Start

Create a new Swift test file for your module, annotate tests with @Test, and replace XCTest assertions with #expect. Ensure tests use Issue.record for failures and follow the Arrange-Act-Assert pattern.

Frequently Asked Questions about swift-testing-guidelines

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write unit tests for Swift StateTree using the Swift Testing framework?

To write Swift StateTree tests, annotate functions with @Test, replace XCTest assertions with #expect, and use Issue.record for failures. Follow the Arrange-Act-Assert pattern across core library, transport, and macros modules.

What is the best way to migrate XCTest assertions to Swift Testing in StateTree modules?

Migrate XCTest assertions by replacing them with #expect for conditions and Issue.record for explicit failures. The Swift Testing framework enforces this pattern to align test style and avoid common pitfalls across StateTree modules.

Does the Swift Testing framework support async tests for Swift StateTree?

Yes, the Swift Testing framework supports async tests for Swift StateTree. You can use @Test annotations for async functions and apply #expect assertions to validate asynchronous state changes and transport operations.

Can I use XCTest for feature tests in Swift StateTree modules?

No, you should avoid XCTest for Swift StateTree feature tests. The guidelines enforce using the Swift Testing framework with @Test and #expect to ensure correct, maintainable test coverage across core modules like matchmaking and transport.

How do I organize Swift Testing test files across different StateTree modules?

Organize Swift Testing files by applying module organization guidance for each StateTree module, such as core library, transport, and macros. Use @Test annotations and #expect to maintain consistent test style across the project.

Why does my Swift StateTree test fail when using Issue.record instead of XCTFail?

Swift StateTree tests require Issue.record to report failures instead of XCTFail. This enforces the Swift Testing framework's structured approach, ensuring failures are recorded correctly during feature tests and test-quality reviews.