Adding a title property

Open ToDoItemTests.swift and add the following import expression right below import XCTest:

@testable import ToDo 

This is needed in order to be able to test the ToDo module. The @testable keyword makes the internal methods of the ToDo module accessible to the test case.

Remove the two template test methods, testExample() and testPerformanceExample().

The title of a to-do item is required. Let's write a test to ensure that an initializer exists that will take a title string. Add the following test method to the end of the test case (but within the ToDoItemTests class):

func test_Init_TakesTitle() { 
  ToDoItem(title: "Foo") 
} 

The static analyzer built into Xcode will complain about Use of unresolved identifier 'ToDoItem' ...

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.