Skip to content

Commit e30df50

Browse files
authored
Merge pull request #150 from jrose-apple/open-for-business
Add 'open' to all public classes and their members.
2 parents 608956d + 5c6ef26 commit e30df50

File tree

6 files changed

+52
-52
lines changed

6 files changed

+52
-52
lines changed

Sources/XCTest/Public/XCAbstractTest.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,20 @@
1515
/// An abstract base class for testing. `XCTestCase` and `XCTestSuite` extend
1616
/// `XCTest` to provide for creating, managing, and executing tests. Most
1717
/// developers will not need to subclass `XCTest` directly.
18-
public class XCTest {
18+
open class XCTest {
1919
/// Test's name. Must be overridden by subclasses.
20-
public var name: String {
20+
open var name: String {
2121
fatalError("Must be overridden by subclasses.")
2222
}
2323

2424
/// Number of test cases. Must be overridden by subclasses.
25-
public var testCaseCount: UInt {
25+
open var testCaseCount: UInt {
2626
fatalError("Must be overridden by subclasses.")
2727
}
2828

2929
/// The `XCTestRun` subclass that will be instantiated when the test is run
3030
/// to hold the test's results. Must be overridden by subclasses.
31-
public var testRunClass: AnyClass? {
31+
open var testRunClass: AnyClass? {
3232
fatalError("Must be overridden by subclasses.")
3333
}
3434

@@ -39,17 +39,17 @@ public class XCTest {
3939
/// ensure compatibility of tests between swift-corelibs-xctest and Apple
4040
/// XCTest, you should not set this property. See
4141
/// https://bugs.swift.org/browse/SR-1129 for details.
42-
public public(set) var testRun: XCTestRun? = nil
42+
open open(set) var testRun: XCTestRun? = nil
4343

4444
/// The method through which tests are executed. Must be overridden by
4545
/// subclasses.
46-
public func perform(_ run: XCTestRun) {
46+
open func perform(_ run: XCTestRun) {
4747
fatalError("Must be overridden by subclasses.")
4848
}
4949

5050
/// Creates an instance of the `testRunClass` and passes it as a parameter
5151
/// to `perform()`.
52-
public func run() {
52+
open func run() {
5353
guard let testRunType = testRunClass as? XCTestRun.Type else {
5454
fatalError("XCTest.testRunClass must be a kind of XCTestRun.")
5555
}
@@ -59,11 +59,11 @@ public class XCTest {
5959

6060
/// Setup method called before the invocation of each test method in the
6161
/// class.
62-
public func setUp() {}
62+
open func setUp() {}
6363

6464
/// Teardown method called after the invocation of each test method in the
6565
/// class.
66-
public func tearDown() {}
66+
open func tearDown() {}
6767

6868
// FIXME: This initializer is required due to a Swift compiler bug on Linux.
6969
// It should be removed once the bug is fixed.

Sources/XCTest/Public/XCTestCase.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ internal var XCTCurrentTestCase: XCTestCase?
3232
/// run by the framework. This class is normally subclassed and extended with
3333
/// methods containing the tests to run.
3434
/// - seealso: `XCTMain`
35-
public class XCTestCase: XCTest {
35+
open class XCTestCase: XCTest {
3636
private let testClosure: (XCTestCase) throws -> Void
3737

3838
/// The name of the test case, consisting of its class name and the method
3939
/// name it will run.
40-
public override var name: String {
40+
open override var name: String {
4141
return _name
4242
}
4343
/// A private setter for the name of this test case.
@@ -48,7 +48,7 @@ public class XCTestCase: XCTest {
4848
/// https://bugs.swift.org/browse/SR-1129 for details.
4949
public var _name: String
5050

51-
public override var testCaseCount: UInt {
51+
open override var testCaseCount: UInt {
5252
return 1
5353
}
5454

@@ -68,11 +68,11 @@ public class XCTestCase: XCTest {
6868
/// https://bugs.swift.org/browse/SR-1129 for details.
6969
public var _performanceMeter: PerformanceMeter?
7070

71-
public override var testRunClass: AnyClass? {
71+
open override var testRunClass: AnyClass? {
7272
return XCTestCaseRun.self
7373
}
7474

75-
public override func perform(_ run: XCTestRun) {
75+
open override func perform(_ run: XCTestRun) {
7676
guard let testRun = run as? XCTestCaseRun else {
7777
fatalError("Wrong XCTestRun class.")
7878
}
@@ -96,7 +96,7 @@ public class XCTestCase: XCTest {
9696

9797
/// Invoking a test performs its setUp, invocation, and tearDown. In
9898
/// general this should not be called directly.
99-
public func invokeTest() {
99+
open func invokeTest() {
100100
setUp()
101101
do {
102102
try testClosure(self)
@@ -120,7 +120,7 @@ public class XCTestCase: XCTest {
120120
/// - Parameter expected: `true` if the failure being reported was the
121121
/// result of a failed assertion, `false` if it was the result of an
122122
/// uncaught exception.
123-
public func recordFailure(withDescription description: String, inFile filePath: String, atLine lineNumber: UInt, expected: Bool) {
123+
open func recordFailure(withDescription description: String, inFile filePath: String, atLine lineNumber: UInt, expected: Bool) {
124124
testRun?.recordFailure(
125125
withDescription: description,
126126
inFile: filePath,
@@ -142,13 +142,13 @@ public class XCTestCase: XCTest {
142142

143143
/// Setup method called before the invocation of any test method in the
144144
/// class.
145-
public class func setUp() {}
145+
open class func setUp() {}
146146

147147
/// Teardown method called after the invocation of every test method in the
148148
/// class.
149-
public class func tearDown() {}
149+
open class func tearDown() {}
150150

151-
public var continueAfterFailure: Bool {
151+
open var continueAfterFailure: Bool {
152152
get {
153153
return true
154154
}

Sources/XCTest/Public/XCTestCaseRun.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,18 @@
1212
//
1313

1414
/// A test run for an `XCTestCase`.
15-
public class XCTestCaseRun: XCTestRun {
16-
public override func start() {
15+
open class XCTestCaseRun: XCTestRun {
16+
open override func start() {
1717
super.start()
1818
XCTestObservationCenter.shared().testCaseWillStart(testCase)
1919
}
2020

21-
public override func stop() {
21+
open override func stop() {
2222
super.stop()
2323
XCTestObservationCenter.shared().testCaseDidFinish(testCase)
2424
}
2525

26-
public override func recordFailure(withDescription description: String, inFile filePath: String?, atLine lineNumber: UInt, expected: Bool) {
26+
open override func recordFailure(withDescription description: String, inFile filePath: String?, atLine lineNumber: UInt, expected: Bool) {
2727
super.recordFailure(
2828
withDescription: "\(test.name) : \(description)",
2929
inFile: filePath,

Sources/XCTest/Public/XCTestRun.swift

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,19 @@
2020
/// A test run collects information about the execution of a test. Failures in
2121
/// explicit test assertions are classified as "expected", while failures from
2222
/// unrelated or uncaught exceptions are classified as "unexpected".
23-
public class XCTestRun {
23+
open class XCTestRun {
2424
/// The test instance provided when the test run was initialized.
2525
public let test: XCTest
2626

2727
/// The time at which the test run was started, or nil.
28-
public private(set) var startDate: Date?
28+
open private(set) var startDate: Date?
2929

3030
/// The time at which the test run was stopped, or nil.
31-
public private(set) var stopDate: Date?
31+
open private(set) var stopDate: Date?
3232

3333
/// The number of seconds that elapsed between when the run was started and
3434
/// when it was stopped.
35-
public var totalDuration: TimeInterval {
35+
open var totalDuration: TimeInterval {
3636
if let stop = stopDate, let start = startDate {
3737
return stop.timeIntervalSince(start)
3838
} else {
@@ -43,33 +43,33 @@ public class XCTestRun {
4343
/// In an `XCTestCase` run, the number of seconds that elapsed between when
4444
/// the run was started and when it was stopped. In an `XCTestSuite` run,
4545
/// the combined `testDuration` of each test case in the suite.
46-
public var testDuration: TimeInterval {
46+
open var testDuration: TimeInterval {
4747
return totalDuration
4848
}
4949

5050
/// The number of tests in the run.
51-
public var testCaseCount: UInt {
51+
open var testCaseCount: UInt {
5252
return test.testCaseCount
5353
}
5454

5555
/// The number of test executions recorded during the run.
56-
public private(set) var executionCount: UInt = 0
56+
open private(set) var executionCount: UInt = 0
5757

5858
/// The number of test failures recorded during the run.
59-
public private(set) var failureCount: UInt = 0
59+
open private(set) var failureCount: UInt = 0
6060

6161
/// The number of uncaught exceptions recorded during the run.
62-
public private(set) var unexpectedExceptionCount: UInt = 0
62+
open private(set) var unexpectedExceptionCount: UInt = 0
6363

6464
/// The total number of test failures and uncaught exceptions recorded
6565
/// during the run.
66-
public var totalFailureCount: UInt {
66+
open var totalFailureCount: UInt {
6767
return failureCount + unexpectedExceptionCount
6868
}
6969

7070
/// `true` if all tests in the run completed their execution without
7171
/// recording any failures, otherwise `false`.
72-
public var hasSucceeded: Bool {
72+
open var hasSucceeded: Bool {
7373
guard isStopped else {
7474
return false
7575
}
@@ -84,7 +84,7 @@ public class XCTestRun {
8484
}
8585

8686
/// Start a test run. Must not be called more than once.
87-
public func start() {
87+
open func start() {
8888
guard !isStarted else {
8989
fatalError("Invalid attempt to start a test run that has " +
9090
"already been started: \(self)")
@@ -99,7 +99,7 @@ public class XCTestRun {
9999

100100
/// Stop a test run. Must not be called unless the run has been started.
101101
/// Must not be called more than once.
102-
public func stop() {
102+
open func stop() {
103103
guard isStarted else {
104104
fatalError("Invalid attempt to stop a test run that has " +
105105
"not yet been started: \(self)")

Sources/XCTest/Public/XCTestSuite.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919
/// suite.addTest(myTest)
2020
/// suite.testCaseCount // 1
2121
/// suite.run()
22-
public class XCTestSuite: XCTest {
23-
public private(set) var tests = [XCTest]()
22+
open class XCTestSuite: XCTest {
23+
open private(set) var tests = [XCTest]()
2424

2525
/// The name of this test suite.
26-
override public var name: String {
26+
open override var name: String {
2727
return _name
2828
}
2929
/// A private setter for the name of this test suite.
@@ -35,15 +35,15 @@ public class XCTestSuite: XCTest {
3535
public let _name: String
3636

3737
/// The number of test cases in this suite.
38-
public override var testCaseCount: UInt {
38+
open override var testCaseCount: UInt {
3939
return tests.reduce(0) { $0 + $1.testCaseCount }
4040
}
4141

42-
public override var testRunClass: AnyClass? {
42+
open override var testRunClass: AnyClass? {
4343
return XCTestSuiteRun.self
4444
}
4545

46-
public override func perform(_ run: XCTestRun) {
46+
open override func perform(_ run: XCTestRun) {
4747
guard let testRun = run as? XCTestSuiteRun else {
4848
fatalError("Wrong XCTestRun class.")
4949
}
@@ -64,7 +64,7 @@ public class XCTestSuite: XCTest {
6464

6565
/// Adds a test (either an `XCTestSuite` or an `XCTestCase` to this
6666
/// collection.
67-
public func addTest(_ test: XCTest) {
67+
open func addTest(_ test: XCTest) {
6868
tests.append(test)
6969
}
7070
}

Sources/XCTest/Public/XCTestSuiteRun.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,46 +18,46 @@
1818
#endif
1919

2020
/// A test run for an `XCTestSuite`.
21-
public class XCTestSuiteRun: XCTestRun {
21+
open class XCTestSuiteRun: XCTestRun {
2222
/// The combined `testDuration` of each test case run in the suite.
23-
public override var totalDuration: TimeInterval {
23+
open override var totalDuration: TimeInterval {
2424
return testRuns.reduce(TimeInterval(0.0)) { $0 + $1.totalDuration }
2525
}
2626

2727
/// The combined execution count of each test case run in the suite.
28-
public override var executionCount: UInt {
28+
open override var executionCount: UInt {
2929
return testRuns.reduce(0) { $0 + $1.executionCount }
3030
}
3131

3232
/// The combined failure count of each test case run in the suite.
33-
public override var failureCount: UInt {
33+
open override var failureCount: UInt {
3434
return testRuns.reduce(0) { $0 + $1.failureCount }
3535
}
3636

3737
/// The combined unexpected failure count of each test case run in the
3838
/// suite.
39-
public override var unexpectedExceptionCount: UInt {
39+
open override var unexpectedExceptionCount: UInt {
4040
return testRuns.reduce(0) { $0 + $1.unexpectedExceptionCount }
4141
}
4242

43-
public override func start() {
43+
open override func start() {
4444
super.start()
4545
XCTestObservationCenter.shared().testSuiteWillStart(testSuite)
4646
}
4747

48-
public override func stop() {
48+
open override func stop() {
4949
super.stop()
5050
XCTestObservationCenter.shared().testSuiteDidFinish(testSuite)
5151
}
5252

5353
/// The test run for each of the tests in this suite.
5454
/// Depending on what kinds of tests this suite is composed of, these could
5555
/// be some combination of `XCTestCaseRun` and `XCTestSuiteRun` objects.
56-
public private(set) var testRuns = [XCTestRun]()
56+
open private(set) var testRuns = [XCTestRun]()
5757

5858
/// Add a test run to the collection of `testRuns`.
5959
/// - Note: It is rare to call this method outside of XCTest itself.
60-
public func addTestRun(_ testRun: XCTestRun) {
60+
open func addTestRun(_ testRun: XCTestRun) {
6161
testRuns.append(testRun)
6262
}
6363

0 commit comments

Comments
 (0)