Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ccabanero/177a54d2be3694f08c4f3c8f02f74394 to your computer and use it in GitHub Desktop.
Save ccabanero/177a54d2be3694f08c4f3c8f02f74394 to your computer and use it in GitHub Desktop.
iOS Unit Test Sample: ViewController can respond to an Unwind Segue
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