O'Reilly logo

Test-Driven iOS Development with Swift 4 - Third Edition by Dr. Dominik Hauser

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Showing the input view

The user should be able to add an item to the list view. As shown in the mockups in Chapter 2, Planning and Structuring Your Test-Driven iOS App, there should be an Add button in the navigation bar that presents the input view controller. We will add the following tests to ItemListViewControllerTests because these are tests about ItemListViewController.

Open ItemListViewControllerTests and add this test:

func test_ItemListViewController_HasAddBarButtonWithSelfAsTarget() { 
  let target = sut.navigationItem.rightBarButtonItem?.target 
  XCTAssertEqual(target as? UIViewController, sut) 
} 

To make this test pass, we need to add a bar button item to the item list view controller. Open Main.storyboard, drag a Bar Button Item

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required