Debugging tests

Sometimes, but usually, rarely, you may need to debug your tests. As with normal code, you can set breakpoints in test code. The debugger then stops the execution of the code at a breakpoint. You can also set breakpoints in the code that will be tested to check whether you have missed something or whether the code you'd like to test is actually executed.

To get a feeling of how this works, let's add an error to a test in the preceding example and debug it. Open FirstDemoTests.swift, and replace the test_MakeHeadline_ReturnsStringWithEachWordStartCapital2() test method with this code:

func test_MakeHeadline_ReturnsStringWithEachWordStartCapital2() { let input = "Here is another Example" let expectedOutput = "Here iS Another ...

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.