A behavior-driven development (BDD) framework and test runner for Swift projects
and playgrounds. It’s compatible with both OS X and Linux.
Usage
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"
}
}
Reporters
Spectre currently has two built-in reporters, Standard and the Dot reporter.
Custom reporters are supported, make a type that conforms to Reporter.
Spectre
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.
Usage
Reporters
Spectre currently has two built-in reporters, Standard and the Dot reporter. Custom reporters are supported, make a type that conforms to
Reporter
.-t
)--tap)
- Test Anything Protocol-compatible outputThe default reporter can be configured via an environment variable. For example:
Standard
The standard reporter produces output as follows:
Passing Tests
Failing Tests
Dot
Using the
-t
argument, you can use the dot reporter.Passing Tests
Failing Tests
Expectation
Equivalence
Truthiness
Error handling
Comparable
Types
Causing a failure
Custom assertions
You can easily provide your own assertions, you just need to throw a failure when the assertion does not meet expectaions.
Examples
The following projects use Spectre:
Installation / Running
Swift Package Manager
Check out Commander as an example.
Playground
You can use Spectre in an Xcode Playground, open
Spectre.playground
in this repository, failures are printed in the console.