Swiftpack.co -  SwiftDocOrg/TAP as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
A Swift package for the Test Anything Protocol (v13)
.package(url: "https://github.com/SwiftDocOrg/TAP.git", from: "0.2.0")


A Swift package for the Test Anything Protocol (v13).


  • Swift 5.3+


You can use TAP as an alternative to XCTest in executable targets or as a custom reporter in test targets.

Running Tests Directly

import TAP

try TAP.run([
    test(1 + 1 == 2), // passes
    test(true == false) // fails
// Prints:
TAP version 13
ok 1
not ok 2
  file: path/to/File.swift
  line: 5

Custom Test Reporting


Swift Package Manager on Linux uses swift-corelibs-xctest, which provides an XCTMain that

Run the following command on macOS to (re)-generate your main test file:

$ swift test --generate-linuxmain

Open the resulting LinuxMain.swift file, add an import statement for the TAP module and register XCTestTAPObserver as a test observer. In Swift 5.4 and later, you can update the XCTMain invocation to include an observers parameter with an instance of XCTestTAPObserver.

#if os(Linux)
import XCTest
import TAP
@testable import TAPTests

#if swift(>=5.4)
arguments: CommandLine.arguments,
observers: [

When you run the swift test command, your test suite will be reported in TAP format.

macOS and iOS

As of Swift 5.3, it's not possible to configure a custom reporter when running tests directly through Swift Package Manager. However, Xcode provides a mechanism for loading custom reports via XCTestObservationCenter.

Create a new file named TestObservation.swift and add it to your test bundle. Import the TAP module, declare a subclass of NSObject named TestObservation, and override its designated initializer to register XCTestTAPObserver with the shared XCTestObservationCenter.

import TAP

final class TestObservation: NSObject {
    override init() {

Add an entry to your test target's Info.plist file designating the fully-qualified name of this class as the NSPrincipalClass.


When you run your test bundle, Xcode will instantiate the principle class first, ensuring that your test observers are registered in time to report the progress of all test runs.


Swift Package Manager

Add the TAP package to your target dependencies in Package.swift:

import PackageDescription

let package = Package(
  name: "YourProject",
  dependencies: [
        url: "https://github.com/SwiftDocOrg/TAP",
        from: "0.2.0"

Add TAP as a dependency to your test target(s):

targets: [
    name: "YourTestTarget",
    dependencies: ["TAP"]),




Mattt (@mattt)


Stars: 19
Last commit: 3 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.


Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API