Skip to content

futuredapp/FTTestingKit

main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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.