Debugging tests
Sometimes, but not often, 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 that 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 methodtest_makeHeadline_shouldCapitalisePassedInString_2()
with this code:// FirstDemoTests.swift func test_makeHeadline_shouldCapitalisePassedInString_2() { let input = "The contextual action menu" let result = blogger.makeHeadline(from: input) let expected = "The ContextuaI Action Menu" XCTAssertEqual(result, expected) }
Have you seen the error that we have...