<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/swift-testing-hopes-entrusted-to-the-future-mjeviiebe" -->

---
title: Swift Testing — Hopes Entrusted to the Future | daily.dev
description: An introduction to Apple's Swift Testing framework compares it against XCTest, covering attributes like @Suite and @Test, traits such as .tags() and .bug(),...
canonical: https://daily.dev/posts/swift-testing-hopes-entrusted-to-the-future-mjeviiebe
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Swift Testing — Hopes Entrusted to the Future | daily.dev
og:description: An introduction to Apple's Swift Testing framework compares it against XCTest, covering attributes like @Suite and @Test, traits such as .tags() and .bug(),...
og:url: https://daily.dev/posts/swift-testing-hopes-entrusted-to-the-future-mjeviiebe
og:image: https://api.daily.dev/og/posts/MjevIiEBe.png
og:image:alt: Swift Testing — Hopes Entrusted to the Future
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Swift Testing — Hopes Entrusted to the Future

**[Medium](https://daily.dev/sources/medium_js)** · 10 min read · 0 upvotes · 0 comments

## Summary

An introduction to Apple's Swift Testing framework compares it against XCTest, covering attributes like @Suite and @Test, traits such as .tags() and .bug(), and macros #expect and #require. The piece walks through converting an XCTest suite for a UIKit view controller into Swift Testing, including handling concurrency issues with @MainActor since Swift Testing runs tests in parallel on background threads rather than serially on the main thread like XCTest. The author also shares a personal, informal observation that Swift Testing ran slower than XCTest in their own project after migrating several features, while cautioning that many variables could explain this.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://medium.com/@MarinaFX/swift-testing-hopes-entrusted-to-the-future-e6af54a6993a>

## Questions this post answers

### How do I annotate a Swift Testing init and test function to avoid crashes when testing UIKit view controllers?

Annotate both the init and the test function with @MainActor. Swift Testing runs tests in parallel on concurrent or background threads, unlike XCTest which runs serialized on the main thread, so UIKit calls that require the main thread can crash unless explicitly marked with @MainActor.

_Developers migrating UIKit test suites can track concurrency gotchas like this one on daily.dev._

### What is the difference between #expect and #require in Swift Testing?

#expect checks a boolean expression and records a failure without stopping the test, while #require throws and exits the test early if the condition fails, replacing XCTest's pattern of conditional binding plus XCTFail. Using #require requires marking the function with try and throws.

_Anyone converting XCTest assertions can compare macro behavior like this on daily.dev while evaluating Swift Testing._

### Is Swift Testing faster than XCTest?

Not necessarily in practice. After converting several features from XCTest to Swift Testing in a real UIKit-based project and running the same tests, Swift Testing tests ran slower, though variables like machine specs, project configuration, and test tuning could explain the difference rather than the framework itself.

_Teams weighing a switch to Swift Testing can follow real-world performance reports like this on daily.dev._

## Similar posts on daily.dev

- [Swift Testing explained with code examples](https://daily.dev/posts/swift-testing-explained-with-code-examples-pgxkvbvk5) · SwiftLee · 1 upvotes · 0 comments
- [Issue 776 – iOS Dev Weekly](https://daily.dev/posts/issue-776-ios-dev-weekly-vvxmjhzob) · iOS Dev Weekly · 0 upvotes · 0 comments
- [Snapshot Testing on iOS: A Setup That Actually Stays Green](https://daily.dev/posts/snapshot-testing-on-ios-a-setup-that-actually-stays-green-wxncwpy3s) · Medium · 0 upvotes · 0 comments

---

Tags: [#testing](https://daily.dev/tags/testing), [#swift](https://daily.dev/tags/swift)

[View this post on daily.dev](https://daily.dev/posts/swift-testing-hopes-entrusted-to-the-future-mjeviiebe)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Swift Testing — Hopes Entrusted to the Future","url":"https://daily.dev/posts/swift-testing-hopes-entrusted-to-the-future-mjeviiebe","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/swift-testing-hopes-entrusted-to-the-future-mjeviiebe"},"datePublished":"2026-09-11T22:05:04.254Z","dateModified":"2026-09-11T22:30:38.439Z","description":"An introduction to Apple's Swift Testing framework compares it against XCTest, covering attributes like @Suite and @Test, traits such as .tags() and .bug(),...","image":"https://media.daily.dev/image/upload/s--CxzD6vbw--/f_auto/v1722860399/public/Placeholder%2005","thumbnailUrl":"https://media.daily.dev/image/upload/s--CxzD6vbw--/f_auto/v1722860399/public/Placeholder%2005","isAccessibleForFree":true,"articleSection":"Medium","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Medium","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/medium","url":"https://daily.dev/sources/medium_js"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/swift-testing-hopes-entrusted-to-the-future-mjeviiebe","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"testing,swift","timeRequired":"PT10M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Medium","item":"https://daily.dev/sources/medium_js"},{"@type":"ListItem","position":3,"name":"Swift Testing — Hopes Entrusted to the Future"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/swift-testing-hopes-entrusted-to-the-future-mjeviiebe#faq","mainEntity":[{"@type":"Question","name":"How do I annotate a Swift Testing init and test function to avoid crashes when testing UIKit view controllers?","acceptedAnswer":{"@type":"Answer","text":"Annotate both the init and the test function with @MainActor. Swift Testing runs tests in parallel on concurrent or background threads, unlike XCTest which runs serialized on the main thread, so UIKit calls that require the main thread can crash unless explicitly marked with @MainActor. Developers migrating UIKit test suites can track concurrency gotchas like this one on daily.dev."}},{"@type":"Question","name":"What is the difference between #expect and #require in Swift Testing?","acceptedAnswer":{"@type":"Answer","text":"#expect checks a boolean expression and records a failure without stopping the test, while #require throws and exits the test early if the condition fails, replacing XCTest's pattern of conditional binding plus XCTFail. Using #require requires marking the function with try and throws. Anyone converting XCTest assertions can compare macro behavior like this on daily.dev while evaluating Swift Testing."}},{"@type":"Question","name":"Is Swift Testing faster than XCTest?","acceptedAnswer":{"@type":"Answer","text":"Not necessarily in practice. After converting several features from XCTest to Swift Testing in a real UIKit-based project and running the same tests, Swift Testing tests ran slower, though variables like machine specs, project configuration, and test tuning could explain the difference rather than the framework itself. Teams weighing a switch to Swift Testing can follow real-world performance reports like this on daily.dev."}}]}
```

