Skip to content

Latest commit

 

History

History
63 lines (47 loc) · 4.76 KB

README.md

File metadata and controls

63 lines (47 loc) · 4.76 KB

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.

  • UIViewController - Makes the UI run-loop behave more consistently to allow specs to test view controller presentation and dismissal with less effort.
  • UITableView - Provides methods mimicking user actions on table views, ensuring all appropriate delegate and data source callbacks are run.
  • UINavigationController - Allows specs to test pushing and popping on the navigation stack without waiting for the UI run-loop.
  • UIButton - Provides convenience methods for interacting with buttons in test.
  • UIBarButtonItem - Provides convenience methods similar to those provided for UIButton.
  • UIAlertController - Allows specs to simply tap on alert actions in order to test their behavior.
  • UITabBarController - Provides convenience methods for selecting tabs.
  • UINavigationBar - Tap on items in a navigation bar.
  • UITextField - Provides convenience methods for entering text. (iOS-only)
  • UISwitch - Provides convenience methods for interacting with switches in test. (iOS-only)
  • UITextView - Provides convenience methods for entering text into a text view. (iOS-only)
  • UIToolbar - Tap on items in a toolbar. (iOS-only)

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