Swiftpack.co -  kylef/Spectre as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
BDD Framework and test runner for Swift projects and playgrounds
.package(url: "https://github.com/kylef/Spectre.git", from: "0.10.0")


Build Status

Special Executive for Command-line Test Running and Execution.

A behavior-driven development (BDD) framework and test runner for Swift projects and playgrounds. It's compatible with both OS X and Linux.


describe("a person") {
  let person = Person(name: "Kyle")

  $0.it("has a name") {
    try expect(person.name) == "Kyle"

  $0.it("returns the name as description") {
    try expect(person.description) == "Kyle"


Spectre currently has two built-in reporters, Standard and the Dot reporter. Custom reporters are supported, make a type that conforms to Reporter.

The default reporter can be configured via an environment variable. For example:

$ env SPECTRE_REPORTER=dot swift test
$ env SPECTRE_REPORTER=tap swift test


The standard reporter produces output as follows:

Passing Tests

Standard Reporter Success

Failing Tests

Standard Reporter Failure


Using the -t argument, you can use the dot reporter.

Passing Tests

Dot Reporter Success

Failing Tests

Dot Reporter Failure



try expect(name) == "Kyle"
try expect(name) != "Kyle"


try expect(alive).to.beTrue()
try expect(alive).to.beFalse()
try expect(alive).to.beNil()

Error handling

try expect(try write()).toThrow()
try expect(try write()).toThrow(FileError.NoPermission)


try expect(5) > 2
try expect(5) >= 2
try expect(5) < 10
try expect(5) <= 10


try expect("kyle").to.beOfType(String.self)

Causing a failure

throw failure("Everything is broken.")

Custom assertions

You can easily provide your own assertions, you just need to throw a failure when the assertion does not meet expectaions.


The following projects use Spectre:

Installation / Running

Swift Package Manager

Check out Commander as an example.


You can use Spectre in an Xcode Playground, open Spectre.playground in this repository, failures are printed in the console.

Spectre in an Xcode Playground


Stars: 372
Last commit: 2 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.

Release Notes

11 weeks ago

Breaking Changes

  • Support for Swift < 4.2 has been dropped.


  • Reporter type can be set via an environment variable. For example, to use dot reporter:

    $ env SPECTRE_REPORTER=dot swift test
  • Additional arguments and options can be passed to Spectre using the SPECTRE_ADDOPTS environment variable, for example:

    $ SPECTRE_ADDOPTS=Tests/SpectreTests/FailureSpec.swift swift test
  • Spectre can be passed a set of files to filter which tests will be executed.

  • Add support for Xcode 12.5.

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