Skip to content

Commit cf6b722

Browse files
committed
Merge pull request #116 from ddunbar/SR-1589
[SR-1589] Add non-throwing testCase() wrapper function.
2 parents 2ce4b57 + c65b335 commit cf6b722

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Sources/XCTest/XCTestCase.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,13 @@ public func testCase<T: XCTestCase>(_ allTests: [(String, (T) -> () throws -> Vo
169169
return (T.self, tests)
170170
}
171171

172+
/// Wrapper function for the non-throwing variant of tests.
173+
/// - seealso: `XCTMain`
174+
public func testCase<T: XCTestCase>(_ allTests: [(String, (T) -> () -> Void)]) -> XCTestCaseEntry {
175+
let tests: [(String, (XCTestCase) throws -> Void)] = allTests.map { ($0.0, test($0.1)) }
176+
return (T.self, tests)
177+
}
178+
172179
private func test<T: XCTestCase>(_ testFunc: (T) -> () throws -> Void) -> (XCTestCase) throws -> Void {
173180
return { testCaseType in
174181
guard let testCase = testCaseType as? T else {

0 commit comments

Comments
 (0)