|
32 | 32 |
|
33 | 33 | /// Starts a test run for the specified test cases.
|
34 | 34 | ///
|
35 |
| -/// This function will not return. If the test cases pass, then it will call `exit(EXIT_SUCCESS)`. If there is a failure, then it will call `exit(EXIT_FAILURE)`. |
36 | 35 | /// Example usage:
|
37 | 36 | ///
|
38 | 37 | /// class TestFoo: XCTestCase {
|
|
50 | 49 | /// // etc...
|
51 | 50 | /// }
|
52 | 51 | ///
|
53 |
| -/// XCTMain([ testCase(TestFoo.allTests) ]) |
| 52 | +/// let exitCode = XCTMain([ testCase(TestFoo.allTests) ]) |
54 | 53 | ///
|
55 |
| -/// Command line arguments can be used to select a particular test case or class to execute. For example: |
| 54 | +/// Command line arguments can be used to select a particular test case or class |
| 55 | +/// to execute. For example: |
56 | 56 | ///
|
57 | 57 | /// ./FooTests FooTestCase/testFoo # Run a single test case
|
58 | 58 | /// ./FooTests FooTestCase # Run all the tests in FooTestCase
|
59 | 59 | ///
|
60 |
| -/// - Parameter testCases: An array of test cases run, each produced by a call to the `testCase` function |
61 |
| -/// - seealso: `testCase` |
| 60 | +/// - Parameters: |
| 61 | +/// - testCases: An array of test cases run, each produced by a call to the |
| 62 | +/// `testCase` function. |
| 63 | +/// - arguments: Command-line arguments to pass to XCTest. By default, the |
| 64 | +/// arguments passed to the process are used. |
| 65 | +/// - observers: Zero or more observers that should observe events that |
| 66 | +/// occur while testing. If `nil` (the default), events are written to |
| 67 | +/// the console. |
| 68 | +/// |
| 69 | +/// - Returns: The exit code to use when the process terminates. `EXIT_SUCCESS` |
| 70 | +/// indicates success, while any other value (including `EXIT_FAILURE`) |
| 71 | +/// indicates failure. |
62 | 72 | @_disfavoredOverload
|
63 | 73 | public func XCTMain(
|
64 | 74 | _ testCases: [XCTestCaseEntry],
|
@@ -143,11 +153,21 @@ public func XCTMain(
|
143 | 153 | }
|
144 | 154 | }
|
145 | 155 |
|
| 156 | +// @available(*, deprecated, message: "Call the overload of XCTMain() that returns an exit code instead.") |
| 157 | +public func XCTMain(_ testCases: [XCTestCaseEntry]) -> Never { |
| 158 | + exit(XCTMain(testCases, arguments: CommandLine.arguments, observers: nil) as CInt) |
| 159 | +} |
| 160 | + |
| 161 | +// @available(*, deprecated, message: "Call the overload of XCTMain() that returns an exit code instead.") |
| 162 | +public func XCTMain(_ testCases: [XCTestCaseEntry], arguments: [String]) -> Never { |
| 163 | + exit(XCTMain(testCases, arguments: arguments, observers: nil) as CInt) |
| 164 | +} |
| 165 | + |
146 | 166 | // @available(*, deprecated, message: "Call the overload of XCTMain() that returns an exit code instead.")
|
147 | 167 | public func XCTMain(
|
148 | 168 | _ testCases: [XCTestCaseEntry],
|
149 |
| - arguments: [String] = CommandLine.arguments, |
150 |
| - observers: [XCTestObservation]? = nil |
| 169 | + arguments: [String], |
| 170 | + observers: [XCTestObservation] |
151 | 171 | ) -> Never {
|
152 | 172 | exit(XCTMain(testCases, arguments: arguments, observers: observers) as CInt)
|
153 | 173 | }
|
0 commit comments