6
votes

Using Xcode 8.2.1

A suite of Swift XCT unit tests isn't highlighting code coverage (with green/red highlighting and numbering) on the corresponding swift file when run.

  • I have ticked code coverage : Gather coverage data in the test scheme.
  • I have tried deleting ~/Library/Developer/Xcode/DerivedData and
    ~/Library/com.apple.dt.Xcode, in finder.
  • I have tried quitting simulator and running again.
  • I have tried running all tests with cmd ⌘ + U, the diamond in the test class, and individual tests.
  • All tests are passing

I know the report navigator can show coverage but it is in a detached way.

1
I'd suggest creating a new blank project (with the checkmark against "unit tests", of course) creating a method to be tested, create a test for that method, turning on code coverage, and then run the tests with ⌘-u. When I do that in Xcode 8.2.1, it works fine, just like matt said. Let's see if the problem is something related to your existing project or your Xcode environment.Rob
By the way, if you hover over the method in the coverage report (like it says in the in image with the arrow that says "Click to go to source code" at developer.apple.com/library/content/documentation/…) and then jump to your source, do you see the coverage there?Rob
Does this answer your question? Xcode9 code coverage is not displayedScottyBlades

1 Answers

9
votes

Works fine on my machine:

enter image description here

enter image description here

Don't forget to choose Editor > Show Code Coverage (you didn't mention that in your little checklist).