Drill into a Partially Covered Line
Let’s start writing a test for the max function, keeping an eye on the code coverage as we progress. Delete test_zero, then add the beginnings of the new test:
| func test_max_with1And2_shouldReturnSomething() { |
| let result = CoveredClass.max(1, 2) |
| } |
Note that there’s no assertion yet. Run tests and go to CoveredClass.swift to see the line-by-line coverage. It should look something like this:
The code coverage gutter now shows a smaller red area and two numbers. The 0 marks the section that tests haven’t touched. Above that is a 1, marking ...
Get iOS Unit Testing by Example 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.