Skip to content

Commit 0829ac1

Browse files
committed
Add notes on XCTestExpectation and XCTWaiter API
1 parent 4819c12 commit 0829ac1

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

proposals/testing/NNNN-targeted-interoperability-swift-testing-and-xctest.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,16 @@ We propose supporting the following XCTest APIs in Swift Testing:
104104
Note that no changes are proposed for the `XCTSkip` API, because they already
105105
feature prominently as a test failure when thrown in Swift Testing.
106106

107+
We also don't propose changes for [`XCTestExpectation`][XCTestExpectation] and
108+
[`XCTWaiter`][XCTWaiter]. They cannot be used safely in a Swift concurrency
109+
context when running Swift Testing tests. Instead, we recommend that users
110+
migrate to Swift concurrency where possible. For code that does not easily map
111+
to `async`/`await` semantics, use [continuations][] and [confirmations][]
112+
instead.
113+
114+
Refer to [Migrating a test from XCTest][XCTest migration validate async] for a
115+
detailed discussion.
116+
107117
We also propose highlighting usage of above XCTest APIs in Swift Testing:
108118

109119
- **Report [runtime warning issues][]** for XCTest API usage in Swift Testing.
@@ -294,15 +304,25 @@ Thanks to Stuart Montgomery, Jonathan Grynspan, and Brian Croom for feedback on
294304
the proposal.
295305

296306
<!-- XCTest -->
307+
297308
[XCTest assertions]: https://developer.apple.com/documentation/xctest/equality-and-inequality-assertions
298309
[unconditional failure]: https://developer.apple.com/documentation/xctest/unconditional-test-failures
299310
[expected failures]: https://developer.apple.com/documentation/xctest/expected-failures
311+
[XCTWaiter]: https://developer.apple.com/documentation/xctest/xctwaiter
312+
[XCTestExpectation]: https://developer.apple.com/documentation/xctest/xctestexpectation
313+
300314
<!-- Swift Testing -->
315+
301316
[Swift Testing expectations]: https://developer.apple.com/documentation/testing/expectations
302317
[Testing for errors]: https://developer.apple.com/documentation/testing/testing-for-errors-in-swift-code
303318
[exit testing]: https://developer.apple.com/documentation/testing/exit-testing
304319
[issue handling traits]: https://developer.apple.com/documentation/testing/issuehandlingtrait
305320
[traits]: https://developer.apple.com/documentation/testing/traits
321+
[confirmations]: https://developer.apple.com/documentation/testing/confirmation
322+
[XCTest migration validate async]: https://developer.apple.com/documentation/testing/migratingfromxctest#Validate-asynchronous-behaviors
323+
306324
<!-- Misc -->
325+
307326
[runtime warning issues]: https://github.com/swiftlang/swift-evolution/blob/main/proposals/testing/0013-issue-severity-warning.md
327+
[continuations]: https://developer.apple.com/documentation/swift/checkedcontinuation
308328
[test cancellation]: https://forums.swift.org/t/pitch-test-cancellation/81847

0 commit comments

Comments
 (0)