Run Swift Tests#

Paid feature

Noctule provides a run configuration and a built-in test runner to execute the tests of a Swift Package Manager project.

Supported Test Frameworks#

Noctule relies on swift test to build and execute tests. Both test engines of the Swift Package Manager are supported and can be enabled independently in the run configuration:

  • Swift Testing, the framework with the @Test and @Suite macros
  • XCTest, the older framework with XCTestCase subclasses

Noctule builds the tree of the test runner from the structured event stream that only Swift Testing emits. XCTest tests are executed, and their output appears in the console, but they are not yet listed as individual items in the test tree.

Run Configuration “Swift Package Test”#

This run configuration executes the tests of a single Swift Package. It is created for you when you launch a test from the editor gutter, and you can also add it manually with Run → Edit Configurations… → Add New Configuration → Swift Package Test.

Settings#

Swift toolchain
The toolchain used to execute the swift test command.
Package directory
The Swift Package directory. The swift test command is executed in this directory.
Program arguments
Additional arguments that are appended to the swift test command line.
Environment variables
Environment variables that are passed to the swift test command.

Test Options#

Test engines
Enable Swift Testing and Enable XCTest control which of the two frameworks is executed. Both are enabled by default. Turning one off passes --disable-swift-testing or --disable-xctest to swift test, which skips building the corresponding test targets.
Sanitize
Turns on runtime checks for erroneous behavior by passing --sanitize to swift test. Available values are Address, Thread, Undefined, scudo and Fuzzer.

Test Inclusion and Exclusion#

Run test cases that match a regular expression
A list of regular expressions passed as --filter. Only matching test cases are executed. A pattern matches against <test-target>.<test-case> or <test-target>.<test-case>/<test>.
Skip test cases that match a regular expression
A list of regular expressions passed as --skip, for example PerformanceTests to leave out a slow test target.

Build Settings#

This section configures the fine-grained build settings, such as the Swift SDK and the build configuration. If you don’t change them, then the default values from Noctule’s directory settings are used.

Test Runner User Interface#

Tests started with this run configuration are shown in your IDE’s usual test runner. The tree lists suites and test cases as they are reported, and you can jump from a result to its declaration in the source code.

File paths in the console output are recognized and turned into links to the corresponding file.

Noctule also adds run icons to the editor gutter next to Swift Testing suites and test functions. The icons are based on the test items reported by SourceKit-LSP and create the matching run configuration for you.

Debugging tests is not supported yet. Please refer to the overview for the current limitations.