Latest 0.1.2
Homepage https://github.com/zhangguol/ViewControllerTestable
License MIT
Platforms ios 10.0
Authors

Travis branch
Codecov branch
CocoaPods
license

What is it?

ViewControllerTestable is an extension to make a UIViewController testable with present, dismiss, and push

Requirements

  • iOS 10.0+
  • Swift 3

Installation

CocoaPods

Add the following to your Podfile.

pod "ViewControllerTestable", '~> 0.1.2'

Git Submodule

git submodule add https://github.com/zhangguol/ViewControllerTestable

Usage

Make a UIViewController testable

You need to import UIViewControllerTestable at first.

To make a UIViewController testable, just make it implement UIViewControllerTestable protocol

extension DemoUIViewController: UIViewControllerTestable {}

Then use

func present(_ viewController: UIViewController,
             from aViewController: UIViewController,
             animated: Bool,
             completion: (() -> Void)?)

to present a view controller. Or use

func dismiss(_ viewController: UIViewController,
             animated: Bool,
             completion: (() -> Void)?)

to dismiss a view controller. Also can use

func push(_ viewController: UIViewController,
          in navigationControler: UINavigationController,
          animated: Bool)

to push a view controller into a UINavigationController

How to test a view controller

Set the view controller’s viewControllerPresent to an instance of MockViewControllerPresenter

let mockPresenter = MockViewControllerPresenter()
viewController.viewControllerPresenter = mockPresenter

Other

License

ViewControllerTestable is released under the MIT license. See LICENSE for details.

Latest podspec

{
    "name": "ViewControllerTestable",
    "version": "0.1.2",
    "summary": "An extension to make a view controller easy to test",
    "description": "ViewControllerTestable is an extension to make a view controllerntestable with present, dismisser, pusher.",
    "homepage": "https://github.com/zhangguol/ViewControllerTestable",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Boxuan Zhang": "[email protected]"
    },
    "platforms": {
        "ios": "10.0"
    },
    "source": {
        "git": "https://github.com/zhangguol/ViewControllerTestable.git",
        "tag": "v0.1.2"
    },
    "source_files": "ViewControllerTestable/**/*.{swift}",
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This