Skip to content
This repository has been archived by the owner on Nov 30, 2018. It is now read-only.
/ Taps Public archive

Taps is a lightweight Unit Test library optimized for asynchronous code and generating TAP13 compatible output.

License

Notifications You must be signed in to change notification settings

vknabel/Taps

Repository files navigation

Taps

Swift 3 GitHub release SwiftPM compatible Plaforms Build Status GitHub license

Taps is a lightweight Unit Test library optimized for asynchronous code. It has been implemented using RxSwift and therefore you can easily test your own Observables with ease, but no RxSwift knowledge is needed.

As the generated output is TAP13 compatible, you can easily customize it yourself. You can either use Taps integrated TapsHarness or you can use the pod TestHarness to customize the output.

You'll find the autogenerated docs here.

Example

Taps assumes all tests to be concurrent. That said it is quite easy to run them:

taps.test("test async completion", timeout: 0.1) { t in
  DispatchQueue.global().async {
    t.pass()
    t.end() // this terminates the test
  }
}

But instead of always being forced to call the t.end() when testing synchronous code, you can add a plan for all expected tests.

taps.test("test does not throw on return", plan: 1) { t in
  t.doesThrow("does throw is ok when throwing") {
    return 1
  }
}

Since Taps uses RxSwift under the hood it really shines, when it comes to testing Observables. If your tested Observable completes, the test will automatically be finished!

tape.test("just emits", timeout: 0.01) { t in
  Observable.just(3)
    .map { $0 + 1 }
    .test(
      onNext: t.notEqual(to: 3, "just emits 3"),
      onError: t.fail(with: "just won't throw'")
    )
}

License

Finite is available under the MIT license. See the LICENSE file for more info.