Xcode Code Coverage Results for UI Testing

I am using Xcode Version 7.1 (7B91b) on my local MAC address. And testing my application on Simulator iPhone 6 (iOS9).

I created unit tests for my application, then I found that the code coverage is about 34%. I decided to create user interface tests to increase code coverage. But, unfortunately, the code coverage has not increased.

I made a simple trial version,

  • create a project using NavBarContrl, FirstTabelViewController and SecondTableViewController, keep default unit tests

  • Leave the unit tests, add one entry in the UI Tests to switch from the first table view controller to the second. (I expect that both the first and second table view controller should be highlighted in the final code coverage report, right?)

  • Make sure code coverage is enabled.

  • Run the tests, then check the code coverage, this is 40%

Take a look at the attached code coverage result, the coverage of the second view controller is zero! although when I watched the simulator, it moved from the first view controller to the second. It cannot be equal to zero.

Code coverage result

Is there anything I don't see here? I tried to find in the official Apple documentation, but can't find a clear contradiction to have code coverage using UI Testing, any suggestions?

+6
source share
1 answer

Make sure you enable Debug Executable in the Test section of the schema settings.

It seems that without this option, Xcode was unable to collect coverage data.

-1
source

All Articles