Skip to content

Instantly share code, notes, and snippets.

@odlp
Created October 7, 2016 10:31
Show Gist options
  • Save odlp/69e7ad5ce77210440ff5643b804e5684 to your computer and use it in GitHub Desktop.
Save odlp/69e7ad5ce77210440ff5643b804e5684 to your computer and use it in GitHub Desktop.
Segue Example Tests
import UIKit
class FirstViewController: UIViewController {
@IBOutlet weak var nextButton: UIButton!
@IBAction func didTapNextButton() {
performSegue(withIdentifier: "moveToSecondScreen", sender: nil)
}
}
import XCTest
import Nimble
@testable import ios_segue_test_example
class SegueExampleTests: XCTestCase {
var vc: FirstViewController!
override func setUp() {
super.setUp()
continueAfterFailure = false
let storyboard = UIStoryboard(name: "Main", bundle: nil)
vc = storyboard.instantiateInitialViewController() as! FirstViewController
vc.appear()
}
func testMovingToTheNextScreen() {
let navVC = UINavigationController(rootViewController: vc)
expect(navVC.visibleViewController).to(beIdenticalTo(vc))
vc.nextButton.tap()
expect(navVC.visibleViewController).toEventually(beAnInstanceOf(SecondViewController.self))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment