How to serialize parameterized tests with Swift Testing 如何使用 Swift Testing 序列化参数化测试
Swift Testing's parameterized tests allow us to send multiple values into a single test, and they'll be run in parallel for maximum performance. If you don't want this – if you wa...
How to force concurrent tests to run on a specific actor 如何强制并发测试在特定actor上运行
Swift Testing and XCTest behave differently when it comes to running tests in parallel: unless you say otherwise, Swift Testing will run both synchronous and asynchronous tests on ...
How to set a time limit for concurrent tests 如何为并发测试设置时间限制
Both Swift Testing and XCTest have simple mechanisms for controlling how long tests should be allowed to run before being considered a failure. This is critically important for con...
How to test AsyncSequence and AsyncStream 如何测试 AsyncSequence 和 AsyncStream
Concurrent Swift code often streams values over time rather than returning them all at once, so it's important to be able to write tests to check an AsyncStream, AsyncSeq...
How to test completion handlers with Swift Testing and XCTest 如何使用 Swift Testing 和 XCTest 测试补全处理程序
When you're dealing with older concurrency code that relies on callback functions that get run when some work completes rather than using Swift concurrency's async/await ...
How to handle concurrency errors in unit tests 如何处理单元测试中的并发错误
Both Swift Testing and XCTest give us three main options for handling errors in tests: we can consider them immediate failures, we can handle them internally and make our own asser...
Introduction to testing Swift concurrency Swift 并发测试简介
Swift's full range of concurrency features work great with unit tests using both the legacy XCTest framework and the new Swift Testing framework.Swift 的全套并发功能非常适合使用旧...
Important: Do not use an actor for your SwiftUI data models 重要提示:请勿将角色用于 SwiftUI 数据模型
Swift’s actors allow us to share data in multiple parts of our app without causing problems with concurrency, because they automatically ensure two pieces of code cannot...
What’s the difference between actors, classes, and structs? Actors、Classes和 Structs 之间有什么区别?
Swift provides four concrete nominal types for defining custom objects: actors, classes, structs, and enums. Each of these works a little differently from the others, but the first...
What is actor reentrancy and how can it cause problems? 什么是 actor 重入性,它如何导致问题?
Actor-isolated functions are reentrant, which means it's possible for one piece of work to begin before a previous piece of work completes. This opens the possibility of subtle bug...