Swift Package Index


Mockups and async extension to XCTestCase


  • The latest stable release is 0.5.0. Released about 1 year ago.
  • The last commit to main was 6 months ago.

Swift Version Compatibility

  • 0.5.0
    5.3
    5.2
    5.1
    5.0
    4.2
  • main
    5.3
    5.2
    5.1
    5.0
    4.2
Full build results

Platform Compatibility

  • 0.5.0 and main
    iOS
    macOS(Intel)
    macOS(ARM)
    Linux
    tvOS
    watchOS
Full build results

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.