Skip to content

Commit a61b37e

Browse files
authored
Merge pull request #465 from apple/jgrynspan/114360933-remove-linuxmain-doc
Remove outdated documentation for LinuxMain.swift.
2 parents aba63a7 + 035f8d4 commit a61b37e

File tree

1 file changed

+0
-36
lines changed

1 file changed

+0
-36
lines changed

README.md

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -19,42 +19,6 @@ The Swift Package Manager integrates directly with XCTest to provide a streamlin
1919

2020
For more information about using XCTest with SwiftPM, see its [documentation](https://github.com/apple/swift-package-manager).
2121

22-
### Test Method Discovery
23-
24-
Unlike the version of XCTest included with Xcode, this version does not use the Objective-C runtime to automatically discover test methods because that runtime is not available on all platforms Swift supports. This means that in certain configurations, the full set of test methods must be explicitly provided to XCTest.
25-
26-
When using XCTest via SwiftPM on macOS, this is not necessary because SwiftPM uses the version of XCTest included with Xcode to run tests. But when using this version of XCTest _without_ SwiftPM, or _with_ SwiftPM on a platform other than macOS (including Linux), the full set of test methods cannot be discovered automatically, and your test target must tell XCTest about them explicitly.
27-
28-
The recommended way to do this is to create a static property in each of your `XCTestCase` subclasses. By convention, this property is named `allTests`, and should contain all of the tests in the class. For example:
29-
30-
```swift
31-
class TestNSURL : XCTestCase {
32-
static var allTests = {
33-
return [
34-
("test_bestNumber", test_bestNumber),
35-
("test_URLStrings", test_URLStrings),
36-
("test_fileURLWithPath", test_fileURLWithPath),
37-
// Other tests go here
38-
]
39-
}()
40-
41-
func test_bestNumber() {
42-
// Write your test here. Most of the XCTAssert functions you are familiar with are available.
43-
XCTAssertTrue(theBestNumber == 42, "The number is wrong")
44-
}
45-
46-
// Other tests go here
47-
}
48-
```
49-
50-
After creating an `allTests` property in each `XCTestCase` subclass, you must tell XCTest about those classes' tests.
51-
52-
If the project is a SwiftPM package which supports macOS, the easiest way to do this is to run `swift test --generate-linuxmain` from a macOS machine. This command generates files within the package's `Tests` subdirectory which contains the necessary source code for passing all test classes and methods to XCTest. These files should be committed to source control and re-generated whenever `XCTestCase` subclasses or test methods are added to or removed from your package's test suite.
53-
54-
If the project is a SwiftPM package but does not support macOS, you may edit the package's default `LinuxMain.swift` file manually to add all `XCTestCase` subclasses.
55-
56-
If the project is not a SwiftPM package, follow the steps in the next section to create an executable which calls the `XCTMain` function manually.
57-
5822
### Standalone Command Line Usage
5923

6024
When used by itself, without SwiftPM, this version of XCTest does not use the external `xctest` CLI test runner included with Xcode to run tests. Instead, you must create your own executable which links `libXCTest.so`, and in your `main.swift`, invoke the `XCTMain` function with an array of the tests from all `XCTestCase` subclasses that you wish to run, wrapped by the `testCase` helper function. For example:

0 commit comments

Comments
 (0)