Swift Testing
Dive deep into Swift Testing related articles, from basics to advanced. Best practices explained with code examples.
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 ...
Parameterized tests in Swift: Reducing boilerplate code
Parameterized tests allow you to run a single test with multiple input parameters without adding much boilerplate code. For example, you might want to run a unit test for all cases of an enum. You can specify a collection of elements to use as input for the unit test, after ...
Using the #require macro for Swift Testing
Swift Testing is Apple's modern replacement library for XCTest and introduces new macros like #require. We've covered the #expect macro before and are about to dive into its companion to set requirements for a given test. Each #require macro needs to pass for a test to continue. It's kind of ...
Stop waiting. Start shipping.Shared runners, queued jobs, throttled Xcode builds — CI shouldn’t slow you down. Flow Swiss gives you dedicated Apple Silicon machines, yours alone. No noisy neighbors, no limits — just raw Mac mini and Mac Studio performance in the cloud, ready in seconds. New Xcode dropped? You’re ready day one. Learn more.
Vapor and Swift Testing: Running tests in parallel
Swift on the Server and Vapor go hand in hand, but using Swift Testing can be challenging initially. Tests run in parallel by default, and it's likely that your tests are running against a localhost database, which requires serial execution of tests. Running tests in parallel drastically improves performance. The ...
Using the #expect macro for Swift Testing
Swift Testing is Apple's Swift framework for writing tests and introduces several macros, including the #expect macro. Where we had to use all kinds of XCAssert variations before, we can now rely on a powerful replacement that will help us debug tests more quickly. Before exploring this specific feature of ...
Using Traits to annotate and customize test behavior
Traits allow you to customize or annotate tests using the Swift Testing framework announced at WWDC 2024. They also allow you to configure common behaviors, like runtime evaluated conditions, to skip certain tests. Before exploring this specific feature of Swift Testing, I encourage you to read my introduction to Swift ...
Swift Testing: Writing a Modern Unit Test
Apple announced the Swift Testing framework during WWDC 2024. It transforms the way we write tests in Swift. A new clear, expressive API makes writing tests more straightforward, while the Xcode user interface communicates with improved feedback when a test fails or succeeds. The testing framework embraces Swift Macros, reducing ...