jwfriese / Fleet

Storyboard injection and helpful extensions to enable fast, consistent UIKit testing in iOS
Apache License 2.0
24 stars 6 forks source link

Fleet Build Status

Fleet is a UIKit-focused testing framework intended for use on iOS and tvOS projects written in Swift.

Installation

See the Installation section for details about installing Fleet in your iOS or tvOS project.

Features

Storyboard injection and mocking

Fleet allows test code to inject into and pull mocks from storyboards. This gives you the best of both worlds -- ability to test your view controllers and their interactions with each other exactly as they are in production code without compromising the ability to isolate any particular view controller for unit testing purposes.

Read more about using Fleet's storyboard features in the Documentation section.

Interaction with UIKit elements

Fleet extends UIKit classes in order to make it easier to test your code's interactions with UIKit. Following are summaries of the major features for each extended class. The Documentation folder contains more information about these features, as well as sample code showing you how they are intended to be used.

Setup for view controller tests

Fleet provides another method of help in setting up view controller alongside storyboard injection and mocking. It makes it easy to set your view controllers up in a proper key application window by providing the following methods:

// Takes a `UIViewController`,  makes it the test app key window's root, and kicks off its lifecycle.
Fleet.setAsAppRootWindow(_:)

// Takes a `UIViewController`,  makes it the root of a navigation stack, kicks off the lifecycle, and
// returns the navigation controller that hosts that view controller.
Fleet.setInAppWindowRootNavigation(_:)

Fleet highly recommends that all view controller tests run inside the test host's key window using one of the above methods. For more discussion on why, go to the relevant section in the FAQ.

FAQ

Examples

To get you started with Fleet, we've created a real, working project that is fully test-driven with the help of Fleet, and which contains many examples of basic tests that you'll likely write in any Swift iOS application.

For more complicated, larger-scale projects that use Fleet, check out the following projects:

FrequentFlyer