Skip to content
This repository was archived by the owner on Aug 5, 2022. It is now read-only.

Commit f4b9286

Browse files
authored
Add some more details to testing guide (#44)
1 parent af6db0b commit f4b9286

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

docs/testing.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
# Testing
22

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.
44

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:
86

97
`$ docker run -v "$PWD:/code" -w /code swift:latest swift test`
108

@@ -14,15 +12,15 @@ Swift supports architecture-specific code. By default, Foundation imports archit
1412

1513
A historically important detail about testing for Linux is the `Tests/LinuxMain.swift` file.
1614

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.
1816
- In Swift versions >= 5.1 < 5.4, tests can be automaticlaly discovered on Linux using `swift test --enable-test-discovery` flag.
1917
- 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.
2018

2119
### Testing for production
2220

2321
- For Swift versions between Swift 5.1 and 5.4, always test with `--enable-test-discovery` to avoid forgetting tests on Linux.
2422

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:
2624
* Run your test suite with TSan (thread sanitizer): `swift test --sanitize=thread`
2725
* Run your test suite with ASan (address sanitizer): `swift test --sanitize=address` and `swift test --sanitize=address -c release -Xswiftc -enable-testing`
2826

0 commit comments

Comments
 (0)