Skip to content

Commit b44d101

Browse files
author
Sean Olszewski
committed
Introduce XCTestCase.ClosureType and XCTRunnableTestCase
1 parent ccef7a6 commit b44d101

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

Sources/XCTest/Private/XCTestCaseSuite.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ internal class XCTestCaseSuite: XCTestSuite {
2424
super.init(name: String(describing: testCaseClass))
2525

2626
for (testName, testClosure) in testCaseEntry.allTests {
27-
// let testCase = testCaseClass.init(name: testName, testClosure: testClosure)
28-
// addTest(testCase)
27+
let closure = XCTestCase.ClosureType.regular(testClosure)
28+
let testCase: XCTestCase = XCTestCase(name: testName, closureType: closure)
29+
addTest(testCase)
2930
}
3031
}
3132

Sources/XCTest/Public/Asynchronous/XCTWaiter.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,7 @@ private extension XCTWaiter {
370370
func cancelPrimitiveWait() {
371371
guard let runLoop = runLoop else { return }
372372
#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
373+
// 81589492 (Warning: XCTWaiter.swift:373:31: 'getCFRunLoop()' is deprecated: Directly accessing the run loop may cause your code to not become portable in the future.)
373374
CFRunLoopStop(runLoop.getCFRunLoop())
374375
#else
375376
runLoop._stop()

Sources/XCTest/Public/XCTestCase.ClosureType.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
//
1313

1414
/// XCTestCase.ClosureType
15-
/// The type of closure that encapsulates the test code to be executed.
15+
/// The type of closure which encapsulates the test code to be executed.
1616
/// This is used to determine the correct concurrency semantics within XCTest so it can support async/await'd code in tests.
1717

1818
import Foundation

Sources/XCTest/Public/XCTestCase.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,6 @@ open class XCTestCase: XCTest {
139139
/// Invoking a test performs its setUp, invocation, and tearDown. In
140140
/// general this should not be called directly.
141141
open func invokeTest() {
142-
// await performSetUpSequence()
143-
// defer { await performTearDownSequence() }
144142
do {
145143
if skip == nil {
146144
try unwrapAndInvokeTestClosure()
@@ -171,8 +169,11 @@ open class XCTestCase: XCTest {
171169
case .async(let closure):
172170
let expectation = XCTestExpectation(description: "invokeTest completion")
173171
Task {
172+
defer { expectation.fulfill() }
173+
await performSetUpSequence()
174+
174175
try await closure(self)
175-
expectation.fulfill()
176+
await performTearDownSequence()
176177
}
177178

178179
// TODO: Copy the comment explaining how this timeout is derived from XCTFailableInvocation in Darin XCTest

0 commit comments

Comments
 (0)