Spectre alternatives and similar libraries
Based on the "Testing" category.
Alternatively, view Spectre alternatives based on common mentions on social networks and blogs.
-
OHHTTPStubs
Stub your network requests easily! Test your apps with fake network data and custom response time, response code and headers! -
UI Testing Cheat Sheet
How do I test this with UI Testing? -
XCTest
The XCTest Project, A Swift core library for providing unit test support -
Mockingjay
An elegant library for stubbing HTTP requests with ease in Swift -
Mocker
Mock Alamofire and URLSession requests without touching your code implementation -
Buildasaur
Automatic testing of your Pull Requests on GitHub and BitBucket using Xcode Server. Keep your team productive and safe. Get up and running in minutes. @buildasaur -
Erik
Erik is an headless browser based on WebKit. An headless browser allow to run functional tests, to access and manipulate webpages using javascript. -
Mussel
A framework for easily testing Push Notifications and Routing in XCUITests -
Mockit
A simple mocking framework for Swift, inspired by the famous http://mockito.org/ -
AutoMockable
AutoMocker is a Swift framework that leverages the type system to let you easily create mocked instances of your data types. -
Guava
A Swift test double library. Guava - looks like an apple but it's not.
Appwrite - The Open Source Firebase alternative introduces iOS support
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of Spectre or a related project?
README
Spectre
*Sp*ecial *E*xecutive for *C*ommand-line *T*est *R*unning and *E*xecution.
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
.
- Standard
- Dot Reporter (
-t
) - Tap Reporter (
--tap)
- Test Anything Protocol-compatible output
The default reporter can be configured via an environment variable. For example:
$ env SPECTRE_REPORTER=dot swift test
$ env SPECTRE_REPORTER=tap swift test
Standard
The standard reporter produces output as follows:
Passing Tests
[Standard Reporter Success](Screenshots/success.png)
Failing Tests
[Standard Reporter Failure](Screenshots/failure.png)
Dot
Using the -t
argument, you can use the dot reporter.
Passing Tests
[Dot Reporter Success](Screenshots/success-dot.png)
Failing Tests
[Dot Reporter Failure](Screenshots/failure-dot.png)
Expectation
Equivalence
try expect(name) == "Kyle"
try expect(name) != "Kyle"
Truthiness
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)
Comparable
try expect(5) > 2
try expect(5) >= 2
try expect(5) < 10
try expect(5) <= 10
Types
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.
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.
[Spectre in an Xcode Playground](Screenshots/Playground.png)