SwiftPM is integrated with XCTest, Apple’s unit test framework. 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.

A convenient way to test on Linux is using Docker. For example:

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

The above command will run the tests using the latest Swift Docker image, utilizing bind mounts to the sources on your file system.

Swift supports architecture-specific code. By default, Foundation imports architecture-specific libraries like Darwin or Glibc. While developing on macOS, you may end up using APIs that are not available on Linux. Since you are most likely to deploy a cloud service on Linux, it is critical to test on Linux.

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

Testing for production