Refactor - example 2

Look at the two tests you have for this feature. They are hard to read. The relevant information for the tests is kind of unstructured. We are going to clean it up.

Replace the two tests with the following code:

func test_MakeHeadline_ReturnsStringWithEachWordStartCapital() { 
  let input           = "this is A test headline" 
  let expectedOutput  = "This Is A Test Headline" 
   

  let headline = viewController.makeHeadline(from: input) 
   

  XCTAssertEqual(headline, expectedOutput) 
} 
 
func test_MakeHeadline_ReturnsStringWithEachWordStartCapital2() { 
  let input           = "Here is another Example" 
  let expectedOutput  = "Here Is Another Example" 
   

  let headline = viewController.makeHeadline(from: input) 
   

  XCTAssertEqual(headline, expectedOutput) 
} 

Now, the tests ...

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.