@@ -86,12 +86,62 @@ class NewInstanceForEachTestTestCase: XCTestCase {
86
86
// CHECK: \t Executed 2 tests, with 0 failures \(0 unexpected\) in \d+\.\d+ \(\d+\.\d+\) seconds
87
87
88
88
89
+ // CHECK: Test Suite 'TeardownBlocksTestCase' started at \d+-\d+-\d+ \d+:\d+:\d+\.\d+
90
+ class TeardownBlocksTestCase : XCTestCase {
91
+ static var allTests = {
92
+ return [
93
+ ( " test_withoutTeardownBlocks " , test_withoutTeardownBlocks) ,
94
+ ( " test_withATeardownBlock " , test_withATeardownBlock) ,
95
+ ( " test_withSeveralTeardownBlocks " , test_withSeveralTeardownBlocks) ,
96
+ ]
97
+ } ( )
98
+
99
+ override func tearDown( ) {
100
+ print ( " In tearDown function " )
101
+ }
102
+
103
+ // CHECK: Test Case 'TeardownBlocksTestCase.test_withoutTeardownBlocks' started at \d+-\d+-\d+ \d+:\d+:\d+\.\d+
104
+ // CHECK: In tearDown function
105
+ // CHECK: Test Case 'TeardownBlocksTestCase.test_withoutTeardownBlocks' passed \(\d+\.\d+ seconds\)
106
+ func test_withoutTeardownBlocks( ) {
107
+ // Intentionally blank
108
+ }
109
+
110
+ // CHECK: Test Case 'TeardownBlocksTestCase.test_withATeardownBlock' started at \d+-\d+-\d+ \d+:\d+:\d+\.\d+
111
+ // CHECK: In teardown block A
112
+ // CHECK: In tearDown function
113
+ // CHECK: Test Case 'TeardownBlocksTestCase.test_withATeardownBlock' passed \(\d+\.\d+ seconds\)
114
+ func test_withATeardownBlock( ) {
115
+ addTeardownBlock {
116
+ print ( " In teardown block A " )
117
+ }
118
+ }
119
+
120
+ // CHECK: Test Case 'TeardownBlocksTestCase.test_withSeveralTeardownBlocks' started at \d+-\d+-\d+ \d+:\d+:\d+\.\d+
121
+ // CHECK: In teardown block C
122
+ // CHECK: In teardown block B
123
+ // CHECK: In tearDown function
124
+ // CHECK: Test Case 'TeardownBlocksTestCase.test_withSeveralTeardownBlocks' passed \(\d+\.\d+ seconds\)
125
+ func test_withSeveralTeardownBlocks( ) {
126
+ addTeardownBlock {
127
+ print ( " In teardown block B " )
128
+ }
129
+ addTeardownBlock {
130
+ print ( " In teardown block C " )
131
+ }
132
+ }
133
+ }
134
+ // CHECK: Test Suite 'TeardownBlocksTestCase' passed at \d+-\d+-\d+ \d+:\d+:\d+\.\d+
135
+ // CHECK: \t Executed 3 tests, with 0 failures \(0 unexpected\) in \d+\.\d+ \(\d+\.\d+\) seconds
136
+
137
+
89
138
XCTMain ( [
90
139
testCase ( SetUpTearDownTestCase . allTests) ,
91
- testCase ( NewInstanceForEachTestTestCase . allTests)
140
+ testCase ( NewInstanceForEachTestTestCase . allTests) ,
141
+ testCase ( TeardownBlocksTestCase . allTests) ,
92
142
] )
93
143
94
144
// CHECK: Test Suite '.*\.xctest' passed at \d+-\d+-\d+ \d+:\d+:\d+\.\d+
95
- // CHECK: \t Executed 3 tests, with 0 failures \(0 unexpected\) in \d+\.\d+ \(\d+\.\d+\) seconds
145
+ // CHECK: \t Executed 6 tests, with 0 failures \(0 unexpected\) in \d+\.\d+ \(\d+\.\d+\) seconds
96
146
// CHECK: Test Suite 'All tests' passed at \d+-\d+-\d+ \d+:\d+:\d+\.\d+
97
- // CHECK: \t Executed 3 tests, with 0 failures \(0 unexpected\) in \d+\.\d+ \(\d+\.\d+\) seconds
147
+ // CHECK: \t Executed 6 tests, with 0 failures \(0 unexpected\) in \d+\.\d+ \(\d+\.\d+\) seconds
0 commit comments