@@ -54,7 +54,10 @@ open class XCTestCase: XCTest {
54
54
55
55
/// The set of expectations made upon this test case.
56
56
private var _allExpectations = [ XCTestExpectation] ( )
57
-
57
+
58
+ private var setupEncounteredError = true
59
+ private static let asyncTestTimeout : TimeInterval = 60 * 60 * 24 * 30
60
+
58
61
internal var expectations : [ XCTestExpectation ] {
59
62
return XCTWaiter . subsystemQueue. sync {
60
63
return _allExpectations
@@ -126,7 +129,9 @@ open class XCTestCase: XCTest {
126
129
open func invokeTest( ) {
127
130
if skip == nil {
128
131
performSetup ( )
129
- performTest ( )
132
+ if !setupEncounteredError {
133
+ performTest ( )
134
+ }
130
135
performTeardown ( )
131
136
}
132
137
@@ -149,9 +154,6 @@ open class XCTestCase: XCTest {
149
154
}
150
155
}
151
156
152
- var shouldInvokeTestClosure = true
153
- static let asyncTestTimeout : TimeInterval = 60 * 60 * 24 * 30
154
-
155
157
func performSetup( ) {
156
158
let asyncSetUpExpectation = XCTestExpectation ( description: " asyncSetUpExpectation " )
157
159
Task {
@@ -160,7 +162,7 @@ open class XCTestCase: XCTest {
160
162
try await setUp ( )
161
163
} catch {
162
164
recordError ( error)
163
- self . shouldInvokeTestClosure = false
165
+ self . setupEncounteredError = true
164
166
}
165
167
}
166
168
_ = XCTWaiter . wait ( for: [ asyncSetUpExpectation] , timeout: Self . asyncTestTimeout)
@@ -169,33 +171,31 @@ open class XCTestCase: XCTest {
169
171
try setUpWithError ( )
170
172
} catch {
171
173
recordError ( error)
172
- self . shouldInvokeTestClosure = false
174
+ self . setupEncounteredError = true
173
175
}
174
176
175
177
setUp ( )
176
178
}
177
179
178
180
func performTest( ) {
179
- if shouldInvokeTestClosure {
180
- switch testClosure {
181
- case . sync( let closure) :
181
+ switch testClosure {
182
+ case . sync( let closure) :
183
+ do {
184
+ try closure ( self )
185
+ } catch {
186
+ recordError ( error)
187
+ }
188
+ case . async ( let closure) :
189
+ let testClosureExpectation = XCTestExpectation ( description: " testClosureExpectation " )
190
+ Task {
191
+ defer { testClosureExpectation. fulfill ( ) }
182
192
do {
183
- try closure ( self )
193
+ try await closure ( self )
184
194
} catch {
185
195
recordError ( error)
186
196
}
187
- case . async ( let closure) :
188
- let testClosureExpectation = XCTestExpectation ( description: " testClosureExpectation " )
189
- Task {
190
- defer { testClosureExpectation. fulfill ( ) }
191
- do {
192
- try await closure ( self )
193
- } catch {
194
- recordError ( error)
195
- }
196
- }
197
- _ = XCTWaiter . wait ( for: [ testClosureExpectation] , timeout: Self . asyncTestTimeout)
198
197
}
198
+ _ = XCTWaiter . wait ( for: [ testClosureExpectation] , timeout: Self . asyncTestTimeout)
199
199
}
200
200
}
201
201
0 commit comments