Created
May 13, 2016 01:07
-
-
Save ccabanero/177a54d2be3694f08c4f3c8f02f74394 to your computer and use it in GitHub Desktop.
iOS Unit Test Sample: ViewController can respond to an Unwind Segue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func testSUT_CanResponseTo_UnwindSegue() { | |
// create source ViewController for unwind segue (i.e. the PlaceSearchViewController | |
let storyboard: UIStoryboard = UIStoryboard(name: "Main_iPhone", bundle: nil) | |
let placeSearchVC = storyboard.instantiateViewControllerWithIdentifier("PlaceSearchViewController") as! PlaceSearchViewController | |
placeSearchVC.targetSearchText = "Lincoln, NE" | |
let _ = placeSearchVC.view | |
// create unwind segue | |
let unwindSegue = UIStoryboardSegue(identifier: "unwindFromPlaceSearchViewController", source: placeSearchVC, destination: systemUnderTest) | |
// simulate that the PlaceSearchViewController is invoked and notifies the SUT | |
systemUnderTest.unwindFromPlaceSearchViewController(unwindSegue) | |
XCTAssertEqual(systemUnderTest.receivedSearchText, "Lincoln, NE") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment