File tree Expand file tree Collapse file tree 2 files changed +52
-0
lines changed
Tests/Functional/TestCaseLifecycle Expand file tree Collapse file tree 2 files changed +52
-0
lines changed Original file line number Diff line number Diff line change
1
+ // RUN: %{swiftc} %s -o %{built_tests_dir}/TestCaseLifecycle
2
+ // RUN: %{built_tests_dir}/TestCaseLifecycle > %t || true
3
+ // RUN: %{xctest_checker} %t %s
4
+ // CHECK: Test Case 'SetUpTearDownTestCase.test_hasValueFromSetUp' started.
5
+ // CHECK: In setUp\(\)
6
+ // CHECK: In test_hasValueFromSetUp\(\)
7
+ // CHECK: In tearDown\(\)
8
+ // CHECK: Test Case 'SetUpTearDownTestCase.test_hasValueFromSetUp' passed \(\d+\.\d+ seconds\).
9
+ // CHECK: Executed 1 test, with 0 failures \(0 unexpected\) in \d+\.\d+ \(\d+\.\d+\) seconds
10
+ // CHECK: Total executed 1 test, with 0 failures \(0 unexpected\) in \d+\.\d+ \(\d+\.\d+\) seconds
11
+
12
+ #if os(Linux) || os(FreeBSD)
13
+ import XCTest
14
+ #else
15
+ import SwiftXCTest
16
+ #endif
17
+
18
+ class SetUpTearDownTestCase : XCTestCase {
19
+ var allTests : [ ( String , ( ) throws -> Void ) ] {
20
+ return [
21
+ ( " test_hasValueFromSetUp " , test_hasValueFromSetUp) ,
22
+ ]
23
+ }
24
+
25
+ var value = 0
26
+
27
+ func setUp( ) {
28
+ print ( " In \( __FUNCTION__) " )
29
+ value = 42
30
+ }
31
+
32
+ func tearDown( ) {
33
+ print ( " In \( __FUNCTION__) " )
34
+ }
35
+
36
+ func test_hasValueFromSetUp( ) {
37
+ print ( " In \( __FUNCTION__) " )
38
+ XCTAssertEqual ( value, 42 )
39
+ }
40
+ }
41
+
42
+ XCTMain ( [ SetUpTearDownTestCase ( ) ] )
Original file line number Diff line number Diff line change 26
26
27
27
/* Begin PBXFileReference section */
28
28
342A33611C470D91001AA02A /* main.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = "<group>"; };
29
+ 342A33631C47383E001AA02A /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = "<group>"; };
29
30
5B5D86DB1BBC74AD00234F36 /* SwiftXCTest.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SwiftXCTest.framework; sourceTree = BUILT_PRODUCTS_DIR; };
30
31
9F320B0D1C4714EC00AB3456 /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = "<group>"; };
31
32
B1384A411C1B3E8700EDF031 /* CONTRIBUTING.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = CONTRIBUTING.md; sourceTree = "<group>"; };
70
71
path = FailureMessagesTestCase;
71
72
sourceTree = "<group>";
72
73
};
74
+ 342A33621C47343C001AA02A /* TestCaseLifecycle */ = {
75
+ isa = PBXGroup;
76
+ children = (
77
+ 342A33631C47383E001AA02A /* main.swift */,
78
+ );
79
+ path = TestCaseLifecycle;
80
+ sourceTree = "<group>";
81
+ };
73
82
5B5D86D11BBC74AD00234F36 = {
74
83
isa = PBXGroup;
75
84
children = (
146
155
DADB975D1C44BE73005E68B6 /* FailingTestSuite */,
147
156
DADB97571C406879005E68B6 /* NegativeAccuracyTestCase */,
148
157
342A33601C470D1E001AA02A /* FailureMessagesTestCase */,
158
+ 342A33621C47343C001AA02A /* TestCaseLifecycle */,
149
159
DA78F7ED1C4039410082E15B /* xctest_checker */,
150
160
);
151
161
path = Functional;
You can’t perform that action at this time.
0 commit comments