Last active
May 12, 2016 19:02
-
-
Save ccabanero/a0fbb675f44a5136d2811d21a77e332a to your computer and use it in GitHub Desktop.
Revisions
-
ccabanero renamed this gist
May 12, 2016 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
ccabanero renamed this gist
May 12, 2016 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
ccabanero renamed this gist
May 12, 2016 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
ccabanero revised this gist
May 11, 2016 . 1 changed file with 33 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -47,4 +47,36 @@ class ViewControllerTest: XCTestCase { let targetIdentifier = systemUnderTest.segueIdentifierName2 XCTAssertTrue(hasSegueWithIdentifier(targetIdentifier)) } } // Unwind Segue Scenario ... inside ViewControllerTest that has an unwind segue ... // MARK: - Navigation // utility for finding segues func hasSegueWithIdentifier(id: String) -> Bool { let segues = systemUnderTest.valueForKey("storyboardSegueTemplates") as? [NSObject] let filtered = segues?.filter({ $0.valueForKey("identifier") as? String == id }) return (filtered?.count > 0) ?? false } func testSUT_HasAnUnwindSegue() { let targetIdentifier = systemUnderTest.segueIdentifierUnwindFromPlacesSearchViewController XCTAssertTrue(hasSegueWithIdentifier(targetIdentifier)) } ... // Unwind Segue Scenario ... inside ViewControllerTest that HANDLES the unwind segue ... // MARK: - Navigation func testSUT_HasUnwindAction_FromPlaceSearchViewController() { XCTAssertTrue(systemUnderTest.respondsToSelector(#selector(systemUnderTest.unwindFromPlaceSearchViewController(_:)))) } ... -
ccabanero revised this gist
May 11, 2016 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -38,13 +38,13 @@ class ViewControllerTest: XCTestCase { func testSUT_HasSegue_ForTransitioningTo_ViewConrollerOne() { let targetIdentifier = systemUnderTest.segueIdentifierName1 // segue identifier as a constant property of ViewController XCTAssertTrue(hasSegueWithIdentifier(targetIdentifier)) } func testSUT_HasSegue_ForTransitioningTo_ViewConrollerTwo() { let targetIdentifier = systemUnderTest.segueIdentifierName2 XCTAssertTrue(hasSegueWithIdentifier(targetIdentifier)) } } -
ccabanero created this gist
May 10, 2016 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,50 @@ import XCTest @testable import YourProjectModule class ViewControllerTest: XCTestCase { var systemUnderTest: ViewController! override func setUp() { super.setUp() //get the storyboard the ViewController under test is inside let storyboard: UIStoryboard = UIStoryboard(name: "Main_iPhone", bundle: nil) //get the ViewController we want to test from the storyboard (note the identifier is the id explicitly set in the identity inspector) systemUnderTest = storyboard.instantiateViewControllerWithIdentifier("ViewController") as! ViewController //load view hierarchy _ = systemUnderTest.view } override func tearDown() { // Put teardown code here. This method is called after the invocation of each test method in the class. super.tearDown() } // MARK: - Storyboard Segues // utility for finding segues func hasSegueWithIdentifier(id: String) -> Bool { let segues = systemUnderTest.valueForKey("storyboardSegueTemplates") as? [NSObject] let filtered = segues?.filter({ $0.valueForKey("identifier") as? String == id }) return (filtered?.count > 0) ?? false } func testSUT_HasSegue_ForTransitioningTo_ViewConrollerOne() { let targetIdentifier = systemUnderTest.segueIdentifierToOne XCTAssertTrue(hasSegueWithIdentifier(targetIdentifier)) } func testSUT_HasSegue_ForTransitioningTo_ViewConrollerTwo() { let targetIdentifier = systemUnderTest.segueIdentifierToTwo XCTAssertTrue(hasSegueWithIdentifier(targetIdentifier)) } }