From cd0a05804db5c33b6c15073d5d8ebe8b2ae66e55 Mon Sep 17 00:00:00 2001 From: Matt Date: Thu, 18 Jul 2024 15:05:41 -0700 Subject: [PATCH 1/3] Update the messaging around the use of deinit for teardown resolves rdar://132007317 --- .../Testing.docc/MigratingFromXCTest.md | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/Sources/Testing/Testing.docc/MigratingFromXCTest.md b/Sources/Testing/Testing.docc/MigratingFromXCTest.md index 825d2315..7350de1b 100644 --- a/Sources/Testing/Testing.docc/MigratingFromXCTest.md +++ b/Sources/Testing/Testing.docc/MigratingFromXCTest.md @@ -94,11 +94,11 @@ For more information about suites and how to declare and customize them, see ### Convert setup and teardown functions -In XCTest, code can be scheduled to run before and after a test using the +In XCTest, you can schedule code to run before a test using the [`setUp()`](https://developer.apple.com/documentation/xctest/xctest/3856481-setup) -and [`tearDown()`](https://developer.apple.com/documentation/xctest/xctest/3856482-teardown) -family of functions. When writing tests using the testing library, implement -`init()` and/or `deinit` instead: +family of functions. When writing tests using the testing library, you can use +`init()` for setup. Your suite's initializer can be async, throwing, or +actor-isolated if necessary. @Row { @Column { @@ -127,9 +127,13 @@ family of functions. When writing tests using the testing library, implement } } -The use of `async` and `throws` is optional. If teardown is needed, declare your -test suite as a `final` class or as an actor rather than as a structure and -implement `deinit`: +In XCTest, you can also schedule work to run after a test using the [`tearDown()`](https://developer.apple.com/documentation/xctest/xctest/3856482-teardown) +family of functions. When writing tests using the testing library, adopt structured + [concurrency](https://docs.swift.org/swift-book/documentation/the-swift-programming-language/concurrency/) +and take advantage of Swift to handle cleanup for you where possible rather +than relying on a dedicated teardown method. If teardown is necessary, declare +your test suite as a `final` class or actor and implement `deinit`. Your cleanup +operations should be quick, synchronous, and non-throwing. @Row { @Column { From e1ae84827a51ad7777227a1ecf18311e060da8c5 Mon Sep 17 00:00:00 2001 From: Matt Date: Thu, 18 Jul 2024 15:52:25 -0700 Subject: [PATCH 2/3] Remove "quick" from deinit. Use code voice around Swift keywords. Remove final as a requirement. --- Sources/Testing/Testing.docc/MigratingFromXCTest.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Sources/Testing/Testing.docc/MigratingFromXCTest.md b/Sources/Testing/Testing.docc/MigratingFromXCTest.md index 7350de1b..0a685e0f 100644 --- a/Sources/Testing/Testing.docc/MigratingFromXCTest.md +++ b/Sources/Testing/Testing.docc/MigratingFromXCTest.md @@ -97,7 +97,7 @@ For more information about suites and how to declare and customize them, see In XCTest, you can schedule code to run before a test using the [`setUp()`](https://developer.apple.com/documentation/xctest/xctest/3856481-setup) family of functions. When writing tests using the testing library, you can use -`init()` for setup. Your suite's initializer can be async, throwing, or +`init()` for setup. Your suite's initializer can be `async`, `throwing`, or actor-isolated if necessary. @Row { @@ -132,8 +132,8 @@ family of functions. When writing tests using the testing library, adopt structu [concurrency](https://docs.swift.org/swift-book/documentation/the-swift-programming-language/concurrency/) and take advantage of Swift to handle cleanup for you where possible rather than relying on a dedicated teardown method. If teardown is necessary, declare -your test suite as a `final` class or actor and implement `deinit`. Your cleanup -operations should be quick, synchronous, and non-throwing. +your test suite as a class or actor, and implement `deinit` with operations +that are synchronous and non-throwing. @Row { @Column { From 21923eaa7d6ed56f9eeaa921508ec3c879f8bab9 Mon Sep 17 00:00:00 2001 From: dreisbach <150207122+medreisbach@users.noreply.github.com> Date: Fri, 19 Jul 2024 09:14:03 -0700 Subject: [PATCH 3/3] Update Sources/Testing/Testing.docc/MigratingFromXCTest.md Co-authored-by: Stuart Montgomery --- Sources/Testing/Testing.docc/MigratingFromXCTest.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Testing/Testing.docc/MigratingFromXCTest.md b/Sources/Testing/Testing.docc/MigratingFromXCTest.md index 0a685e0f..d1e74658 100644 --- a/Sources/Testing/Testing.docc/MigratingFromXCTest.md +++ b/Sources/Testing/Testing.docc/MigratingFromXCTest.md @@ -97,7 +97,7 @@ For more information about suites and how to declare and customize them, see In XCTest, you can schedule code to run before a test using the [`setUp()`](https://developer.apple.com/documentation/xctest/xctest/3856481-setup) family of functions. When writing tests using the testing library, you can use -`init()` for setup. Your suite's initializer can be `async`, `throwing`, or +`init()` for setup. Your suite's initializer can be `async`, `throws`, or actor-isolated if necessary. @Row {