Swiftpack.co - Package - futuredapp/FTTestingKit
FTTestingKit logo

FTTestingKit

Cocoapods Cocoapods platforms Cocoapods

A set of helpers for simple creation of mockups, random values and testing of asynchronous code.

Installation

When using Swift package manager add this line to your dependencies or install using Xcode 11 or newer:

.package(url: "https://github.com/futuredapp/FTTestingKit.git", from: "0.5.0")

When using CocoaPods add following line to your Podfile:

pod 'FTTestingKit', '~> 0.5'

When using PromiseKit you can use either FTTestingKitPromiseKit target for testing promises or add subspec to your Podfile:

pod 'FTTestingKit', '~> 0.5', subspecs: ['PromiseKit']

Features

Main features of this library are generating mockups, random values, arrays and asynchronous testing.

Mockups

For simple repeated execution the library offers Ruby-like extension on Int type. This is helpful in measurement tests.

10.times {
    doSomething()
}
10.times(doSomething)

This extension can create arrays too:

10.times {
    Int.random()
}
10.times(String.random)

The framework extends some basic types (Date, String) with random generation similar to Int. All these types conform to Mockup protocol which formally describes this functionality.

Date.random()
String.random()
Int.random(count: 10)

Expectations

The framework extends XCTestCase with simple methods to call transactional asynchronous test like this:

expect(within: 0.5) { reply in
    DispatchQueue.main.asyncAfter(deadline: .now() + 0.05) {
        reply(.success)
    }
}

Extension for PromiseKit builds on this and offers testing promises using so-called belief in promise method:

believe(for: 0.5, in: someFunctionReturningPromise())

Author

Matěj Kašpar Jirásek, matej.jirasek@futured.app

License

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

Github

link
Stars: 0

Dependencies

Used By

Total: 0

Releases

Futured TestingKit - 2020-01-20 13:17:45

Rebranding - 2020-01-08 08:32:22

Update contacts and company name.

Documentation - 2019-10-21 11:42:28

First usable version - 2019-10-18 16:55:17

- 2019-08-19 08:58:51