Skip to content

Commit ef8bbe4

Browse files
committed
Update tests to meet the new requirements
* Add XCTestCaseType conformances and update XCTMain invocation * Use the static allTests property
1 parent 1d51771 commit ef8bbe4

File tree

6 files changed

+18
-18
lines changed

6 files changed

+18
-18
lines changed

Tests/Functional/ErrorHandling/main.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#endif
2828

2929
class ErrorHandling: XCTestCase {
30-
var allTests: [(String, () throws -> ())] {
30+
static var allTests: [(String, ErrorHandling -> () throws -> Void)] {
3131
return [
3232
// Tests for XCTAssertThrowsError
3333
("test_shouldButDoesNotThrowErrorInAssertion", test_shouldButDoesNotThrowErrorInAssertion),
@@ -39,7 +39,7 @@ class ErrorHandling: XCTestCase {
3939
("test_canButDoesNotThrowErrorFromTestMethod", test_canButDoesNotThrowErrorFromTestMethod),
4040

4141
// Tests for throwing assertion expressions
42-
("test_assertionExpressionCanThrow", test_assertionExpressionCanThrow),
42+
("test_assertionExpressionCanThrow", test_assertionExpressionCanThrow),
4343
]
4444
}
4545

@@ -103,4 +103,4 @@ class ErrorHandling: XCTestCase {
103103
}
104104
}
105105

106-
XCTMain([ErrorHandling()])
106+
XCTMain([testCase(ErrorHandling.allTests)])

Tests/Functional/FailingTestSuite/main.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#endif
2323

2424
class PassingTestCase: XCTestCase {
25-
var allTests: [(String, () throws -> ())] {
25+
static var allTests: [(String, PassingTestCase -> () throws -> Void)] {
2626
return [
2727
("test_passes", test_passes),
2828
]
@@ -34,7 +34,7 @@ class PassingTestCase: XCTestCase {
3434
}
3535

3636
class FailingTestCase: XCTestCase {
37-
var allTests: [(String, () throws -> ())] {
37+
static var allTests: [(String, FailingTestCase -> () throws -> Void)] {
3838
return [
3939
("test_passes", test_passes),
4040
("test_fails", test_fails),
@@ -56,6 +56,6 @@ class FailingTestCase: XCTestCase {
5656
}
5757

5858
XCTMain([
59-
PassingTestCase(),
60-
FailingTestCase(),
59+
testCase(PassingTestCase.allTests),
60+
testCase(FailingTestCase.allTests),
6161
])

Tests/Functional/FailureMessagesTestCase/main.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878

7979
// Regression test for https://github.com/apple/swift-corelibs-xctest/pull/22
8080
class FailureMessagesTestCase: XCTestCase {
81-
var allTests : [(String, () throws -> Void)] {
81+
static var allTests: [(String, FailureMessagesTestCase -> () throws -> Void)] {
8282
return [
8383
("testAssert", testAssert),
8484
("testAssertEqualOptionals", testAssertEqualOptionals),
@@ -194,4 +194,4 @@ class FailureMessagesTestCase: XCTestCase {
194194
}
195195
}
196196

197-
XCTMain([FailureMessagesTestCase()])
197+
XCTMain([testCase(FailureMessagesTestCase.allTests)])

Tests/Functional/NegativeAccuracyTestCase/main.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
// Regression test for https://github.com/apple/swift-corelibs-xctest/pull/7
2424
class NegativeAccuracyTestCase: XCTestCase {
25-
var allTests: [(String, () throws -> ())] {
25+
static var allTests: [(String, NegativeAccuracyTestCase -> () throws -> Void)] {
2626
return [
2727
("test_equalWithAccuracy_passes", test_equalWithAccuracy_passes),
2828
("test_equalWithAccuracy_fails", test_equalWithAccuracy_fails),
@@ -48,4 +48,4 @@ class NegativeAccuracyTestCase: XCTestCase {
4848
}
4949
}
5050

51-
XCTMain([NegativeAccuracyTestCase()])
51+
XCTMain([testCase(NegativeAccuracyTestCase.allTests)])

Tests/Functional/SingleFailingTestCase/main.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
#endif
1515

1616
class SingleFailingTestCase: XCTestCase {
17-
var allTests: [(String, () throws -> ())] {
17+
static var allTests: [(String, SingleFailingTestCase -> () throws -> Void)] {
1818
return [
19-
("test_fails", test_fails),
19+
("test_fails", test_fails)
2020
]
2121
}
2222

@@ -25,4 +25,4 @@ class SingleFailingTestCase: XCTestCase {
2525
}
2626
}
2727

28-
XCTMain([SingleFailingTestCase()])
28+
XCTMain([testCase(SingleFailingTestCase.allTests)])

Tests/Functional/TestCaseLifecycle/main.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#endif
2222

2323
class SetUpTearDownTestCase: XCTestCase {
24-
var allTests: [(String, () throws -> Void)] {
24+
static var allTests: [(String, SetUpTearDownTestCase -> () throws -> Void)] {
2525
return [
2626
("test_hasValueFromSetUp", test_hasValueFromSetUp),
2727
]
@@ -47,7 +47,7 @@ class SetUpTearDownTestCase: XCTestCase {
4747
}
4848

4949
class NewInstanceForEachTestTestCase: XCTestCase {
50-
var allTests: [(String, () throws -> Void)] {
50+
static var allTests: [(String, NewInstanceForEachTestTestCase -> () throws -> Void)] {
5151
return [
5252
("test_hasInitializedValue", test_hasInitializedValue),
5353
("test_hasInitializedValueInAnotherTest", test_hasInitializedValueInAnotherTest),
@@ -67,6 +67,6 @@ class NewInstanceForEachTestTestCase: XCTestCase {
6767
}
6868

6969
XCTMain([
70-
SetUpTearDownTestCase(),
71-
NewInstanceForEachTestTestCase()
70+
testCase(SetUpTearDownTestCase.allTests),
71+
testCase(NewInstanceForEachTestTestCase.allTests)
7272
])

0 commit comments

Comments
 (0)