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

Get Test-Driven iOS Development with Swift 4 - Third Edition 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.