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

Conducting the first tests

Open Project Navigator and select the ToDoTests group. Add a new Unit Test Case Class and call it ItemListDataProviderTests. Add the @testable import ToDo import statement and remove the two test template methods.

The table view should have two sections--one for unchecked to-do items and the other for checked items. Add the following test to ItemListDataProviderTests:

func test_NumberOfSections_IsTwo() { 
  let sut = ItemListDataProvider() 
  let tableView = UITableView() 
  tableView.dataSource = sut 
   

  let numberOfSections = tableView.numberOfSections 
  XCTAssertEqual(numberOfSections, 2) 
} 

First, we create an instance of ItemListDataProvider, set up the table view, and then we check whether the table view has the expected ...

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