Give your simulator superpowers

RocketSim: An Essential Developer Tool
as recommended by Apple

Subscribe to my YouTube Channel

Swift Testing Agent Skill: Write high quality tests with AI

Swift Testing is the standard for writing tests in Swift, but it’s not always applied correctly in agentic development. I’ve felt the pain myself while working more and more with agents, and decided to convert all my Swift Testing articles into a new agent skill.

I also looked up latest best practices inside Apple’s documentation and WWDC sessions, combining them all into an in-depth Agent Skill ready for you to use.

A new Agent Skill for writing tests with Swift Testing

If you’re new to Swift Testing: it’s Apple’s replacement for XCTest. I’ve migrated all my tests to use this new framework and the great news is that I’ve been using this new Agent Skill for it!

The skill is knowledgeable about all that the Swift Testing framework offers. It currently offers this structure:

swift-testing-expert/
  SKILL.md
  references/
    _index.md
    async-testing-and-waiting.md - Async waiting, continuations, and callback-event testing
    expectations.md - #expect, #require, throw checks, and known issues
    fundamentals.md - @Test, suites, structure, and naming patterns
    migration-from-xctest.md - Incremental XCTest coexistence and migration strategy
    parallelization-and-isolation.md - Parallel defaults, randomized order, and .serialized usage
    parameterized-testing.md - Single/multi-argument tests, zip pairing, and scaling
    performance-and-best-practices.md - High-signal testing defaults for speed, determinism, and flakiness prevention
    traits-and-tags.md - Traits, tags, conditions, bug links, and test-plan filtering
    xcode-workflows.md - Test navigator/report workflows and diagnostics practices

I deliberately decided not to force your codebases into any direction. As in, I won’t say an agent always has to do Test Driven Development (TDD). Though, if you wonder, I do recommend doing it as it’s a great way for agents to only return back to you when the tests are green.

The above structure shows that there’s fundamentals coverage, but also in-depth knowledge on performance, best practices, and migrating from XCTest.

FREE 5-day email course: The Swift Concurrency Playbook by Antoine van der Lee

FREE 5-Day Email Course: The Swift Concurrency Playbook

A FREE 5-day email course revealing the 5 biggest mistakes iOS developers make with with async/await that lead to App Store rejections And migration projects taking months instead of days (even if you've been writing Swift for years)

Guiding Agents on best practices

The faster your tests are, the quicker an agent can get back to you. I’ve used this skill to refactor RocketSim‘s unit tests.

The Swift Testing Agent Skill works great for refactoring XCTest into the modern framework.
The Swift Testing Agent Skill works great for refactoring XCTest into the modern framework.

I did this in a few phases:

  • Migrating from XCTest to Swift Testing
  • Rewrote both tests and business logic to better support parallelization
  • Analyzed for flaky tests by running the suite in random order, multiple times

Altogether, my test suite became more stable and much faster. The closing loop for an agent to complete became faster, making my productivity overall better.

Before using this skill, I’ve seen agents making mistakes like adding the serliazed tag or @MainActor attribute for no reason. These are killers for fast test execution. After using the skill, my tests run mostly in parallel and I even got surprised by refactors into parameterized tests.

Swift Testing Agent Skill: Now available open-sourced

By now, you’re likely excited to get started. You can find the skill on GitHub at AvdLee/Swift-Testing-Agent-Skill. Feel free to open a pull request to contribute, and make sure to also check out my other skills:

Conclusion

By installing specific Agent Skills, you’re training your agents to write high-quality Swift code. Higher quality from the get go means less time spent on reviewing and improving. Constantly analyze your workflows and see where it can be improved, as these upgrades compound over time.

If you want to improve your AI development knowledge, even more, check out the AI Development Category page. Feel free to contact me or tweet me on Twitter if you have any additional tips or feedback.

Thanks!

 
Antoine van der Lee

Written by

Antoine van der Lee

iOS Developer since 2010, former Staff iOS Engineer at WeTransfer and currently full-time Indie Developer & Founder at SwiftLee. Writing a new blog post every week related to Swift, iOS and Xcode. Regular speaker and workshop host.

Are you ready to

Turn your side projects into independence?

Learn my proven steps to transform your passion into profit.