You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
-36Lines changed: 0 additions & 36 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,42 +19,6 @@ The Swift Package Manager integrates directly with XCTest to provide a streamlin
19
19
20
20
For more information about using XCTest with SwiftPM, see its [documentation](https://github.com/apple/swift-package-manager).
21
21
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
-
classTestNSURL : XCTestCase {
32
-
staticvar 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
-
functest_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
-
58
22
### Standalone Command Line Usage
59
23
60
24
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