Test Code-Based Push Navigation
We’ll start our testing with code-based navigation, taking push navigation first. Since all our navigation is triggered by button taps, follow Test Button Taps to add a test suite ViewControllerTests with a test named test_tappingCodePushButton_shouldPushCodeNextViewController. This also means editing Main.storyboard to give the view controller a Storyboard ID. Also follow Make a Test Helper for Button Taps to add the tap(_:) helper. Have the test tap the codePushButton outlet. Run the tests, which should pass so far.
The @IBAction connected to codePushButton tells the view controller’s navigationController to do a push. But since the test instantiates ViewController in isolation, it has no navigation controller ...
Get iOS Unit Testing by Example now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.