Skip to content

Commit 468177c

Browse files
committed
Add test for behavior when classes fail to override allTests
1 parent e916cce commit 468177c

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// RUN: %{swiftc} %s -o %{built_tests_dir}/MissingAllTestsTestCase
2+
// RUN: %{built_tests_dir}/MissingAllTestsTestCase > %t || true
3+
// RUN: %{xctest_checker} %t %s
4+
// CHECK: Test Case 'MissingAllTestsTestCase.missingTests' started.
5+
// CHECK: \<EXPR\>:0: unexpected error: MissingAllTestsTestCase.missingTests : threw error "XCTestCase subclasses must override the `allTests` property to list the individual tests they provide" -
6+
// CHECK: Test Case 'MissingAllTestsTestCase.missingTests' failed \(\d+\.\d+ seconds\).
7+
// CHECK: Executed 1 test, with 1 failure \(1 unexpected\) in \d+\.\d+ \(\d+\.\d+\) seconds
8+
// CHECK: Total executed 1 test, with 1 failure \(1 unexpected\) in \d+\.\d+ \(\d+\.\d+\) seconds
9+
10+
#if os(Linux) || os(FreeBSD)
11+
import XCTest
12+
#else
13+
import SwiftXCTest
14+
#endif
15+
16+
class MissingAllTestsTestCase: XCTestCase {
17+
func test_doesNotExecute() {
18+
XCTAssert(false)
19+
}
20+
}
21+
22+
XCTMain([MissingAllTestsTestCase()])

XCTest.xcodeproj/project.pbxproj

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
/* Begin PBXFileReference section */
2828
342A33631C47383E001AA02A /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = "<group>"; };
29+
34ED8F1C1C487143000DEDFC /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = "<group>"; };
2930
5B5D86DB1BBC74AD00234F36 /* SwiftXCTest.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SwiftXCTest.framework; sourceTree = BUILT_PRODUCTS_DIR; };
3031
9F320B0D1C4714EC00AB3456 /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = "<group>"; };
3132
B1384A411C1B3E8700EDF031 /* CONTRIBUTING.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = CONTRIBUTING.md; sourceTree = "<group>"; };
@@ -70,6 +71,14 @@
7071
path = SetUpTearDownTestCase;
7172
sourceTree = "<group>";
7273
};
74+
34ED8F1B1C48711B000DEDFC /* MissingAllTestsTestCase */ = {
75+
isa = PBXGroup;
76+
children = (
77+
34ED8F1C1C487143000DEDFC /* main.swift */,
78+
);
79+
path = MissingAllTestsTestCase;
80+
sourceTree = "<group>";
81+
};
7382
5B5D86D11BBC74AD00234F36 = {
7483
isa = PBXGroup;
7584
children = (
@@ -146,6 +155,7 @@
146155
DADB975D1C44BE73005E68B6 /* FailingTestSuite */,
147156
DADB97571C406879005E68B6 /* NegativeAccuracyTestCase */,
148157
342A33621C47343C001AA02A /* SetUpTearDownTestCase */,
158+
34ED8F1B1C48711B000DEDFC /* MissingAllTestsTestCase */,
149159
DA78F7ED1C4039410082E15B /* xctest_checker */,
150160
);
151161
path = Functional;

0 commit comments

Comments
 (0)