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
{{ message }}
This repository was archived by the owner on Aug 5, 2022. It is now read-only.
Copy file name to clipboardExpand all lines: docs/testing.md
+4-6Lines changed: 4 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,8 @@
1
1
# Testing
2
2
3
-
Running `swift test` from the terminal will trigger the unit tests (or triggering the test action in Xcode).
3
+
SwiftPM is integrated with [XCTest, Apple’s unit test framework](https://developer.apple.com/documentation/xctest). Running `swift test` from the terminal, or triggering the test action in your IDE (Xcode or similar), will run all of your XCTest test cases. Test results will be displayed in your IDE or printed out to the terminal.
4
4
5
-
SwiftPM is integrated with [XCTest, Apple’s unit test framework](https://developer.apple.com/documentation/xctest). Test results will be displayed in Xcode or printed out to the terminal.
6
-
7
-
Like building on Linux, testing on Linux requires the use of Docker. For example:
5
+
A convenient way to test on Linux is using Docker. For example:
8
6
9
7
`$ docker run -v "$PWD:/code" -w /code swift:latest swift test`
10
8
@@ -14,15 +12,15 @@ Swift supports architecture-specific code. By default, Foundation imports archit
14
12
15
13
A historically important detail about testing for Linux is the `Tests/LinuxMain.swift` file.
16
14
17
-
- In Swift versions 5.4 and newer tests are automaticlaly discovered on all platforms, no special file or flag needed.
15
+
- In Swift versions 5.4 and newer tests are automatically discovered on all platforms, no special file or flag needed.
18
16
- In Swift versions >= 5.1 < 5.4, tests can be automaticlaly discovered on Linux using `swift test --enable-test-discovery` flag.
19
17
- In Swift versions older than 5.1 the `Tests/LinuxMain.swift` file provides SwiftPM an index of all the tests it needs to run on Linux and it is critical to keep this file up-to-date as you add more unit tests. To regenerate this file, run `swift test --generate-linuxmain` after adding tests. It is also a good idea to include this command as part of your continuous integration setup.
20
18
21
19
### Testing for production
22
20
23
21
- For Swift versions between Swift 5.1 and 5.4, always test with `--enable-test-discovery` to avoid forgetting tests on Linux.
24
22
25
-
- Make use of the sanitizers. Before running code in production, do the following:
23
+
- Make use of the sanitizers. Before running code in production, and preferably as a regular part of your CI process, do the following:
26
24
* Run your test suite with TSan (thread sanitizer): `swift test --sanitize=thread`
27
25
* Run your test suite with ASan (address sanitizer): `swift test --sanitize=address` and `swift test --sanitize=address -c release -Xswiftc -enable-testing`
0 commit comments