Swift Package Index


A micro-framework for Table Driven Tests.


  • The latest stable release is 0.3.3. Released over 1 year ago.
  • The last commit to master was over 1 year ago.

Swift Version Compatibility

  • 0.3.3 and master
    5.3
    5.2
    5.1
    5.0
    4.2
Full build results

Platform Compatibility

  • 0.3.3 and master
    iOS
    macOS(Intel)
    macOS(ARM)
    Linux
    tvOS
    watchOS
Full build results

Tablier

Build Status codecov Swift 4.2 Swift 5.0 CocoaPods compatible Carthage compatible SPM compatible Supports iOS, macOS, tvOS and Linux MIT License

A micro-framework for Table Driven Tests.

A screenshot to see how it works

Features

  • ☑️ Dead simple syntax
  • ☑️ Run async tests in parallel
  • ☑️ No additional dependency aside from XCTest
  • ☑️ Use with Quick, or any other XCTest-based testing framework
  • ☑️ Fully tested

Installation

Swift Package Manager

.package(url: "https://github.com/akkyie/Tablier", from: "0.2.0")

Cocoapods

target 'YourTests' do
    inherit! :search_paths
    pod 'Tablier'
end

Carthage

github "akkyie/Tablier"

Usage

You can define a test recipe to test your classes, structs or functions.

final class MyParseTests: XCTestCase {
    func testMyParse() {
        let recipe = Recipe<String, Int>(sync: { input in
            // `myParse` here is what you want to test
            let output: Int = try myParse(input) // it fails if an error is thrown
            return output
        })
...

Then you can list inputs and expected outputs for the recipe, to run the actual test for it.

...
        recipe.assert(with: self) {
            $0.when("1").expect(1)
            $0.when("1234567890").expect(1234567890)
            $0.when("-0x42").expect(-0x42)
        }
    }
}

Defining a recipe with async functions is also supported.

let recipe = Recipe<String, Int>(async: { input, complete in
    myComplexAndSlowParse(input) { (result: Int?, error: Error?) in
        complete(result, error)
    }
})

Note

When an error is thrown in the sync initalizer or the completion handler is called with an error, the test case is considered as failed for now. Testing errors will be supported in the future.

Examples

License

MIT. See LICENSE.