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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.