Skip to content

Commit 51793b2

Browse files
committed
Update the README to correspond to the new API
1 parent ff8fb04 commit 51793b2

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,14 @@ You may add tests for XCTest by including them in the `Tests/Functional/` direct
5858

5959
### Additional Considerations for Swift on Linux
6060

61-
When running on the Objective-C runtime, XCTest is able to find all of your tests by simply asking the runtime for the subclasses of `XCTestCase`. It then finds the methods that start with the string `test`. This functionality is not currently present when running on the Swift runtime. Therefore, you must currently provide an additional property called `allTests` in your `XCTestCase` subclass. This method lists all of the tests in the test class. The rest of your test case subclass still contains your test methods.
61+
When running on the Objective-C runtime, XCTest is able to find all of your tests by simply asking the runtime for the subclasses of `XCTestCase`. It then finds the methods that start with the string `test`. This functionality is not currently present when running on the Swift runtime. Therefore, you must currently provide an additional property, conventionally named `allTests`, in your `XCTestCase` subclass. This method lists all of the tests in the test class. The rest of your test case subclass still contains your test methods.
6262

6363
```swift
6464
class TestNSURL : XCTestCase {
65-
var allTests : [(String, () -> Void)] {
65+
static var allTests : [(String, TestNSURL -> () throws -> Void)] {
6666
return [
6767
("test_URLStrings", test_URLStrings),
68-
("test_fileURLWithPath_relativeToURL", test_fileURLWithPath_relativeToURL ),
68+
("test_fileURLWithPath_relativeToURL", test_fileURLWithPath_relativeToURL),
6969
("test_fileURLWithPath", test_fileURLWithPath),
7070
("test_fileURLWithPath_isDirectory", test_fileURLWithPath_isDirectory),
7171
// Other tests go here
@@ -81,10 +81,10 @@ class TestNSURL : XCTestCase {
8181
}
8282
```
8383

84-
Also, this version of XCTest does not use the external test runner binary. Instead, create your own executable which links `libXCTest.so`. In your `main.swift`, invoke the `XCTMain` function with an array of instances of the test cases that you wish to run. For example:
84+
Also, this version of XCTest does not use the external test runner binary. Instead, create your own executable which links `libXCTest.so`. In your `main.swift`, invoke the `XCTMain` function with an array of the test cases classes that you wish to run, wrapped by the `testCase` helper function. For example:
8585

8686
```swift
87-
XCTMain([TestNSString(), TestNSArray(), TestNSDictionary()])
87+
XCTMain([testCase(TestNSString.allTests), testCase(TestNSArray.allTests), testCase(TestNSDictionary.allTests)])
8888
```
8989

9090
The `XCTMain` function does not return, and will cause your test app to exit with either `0` for success or `1` for failure.

0 commit comments

Comments
 (0)