Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode: code coverage percentage

Any of you knows how can I get percentage of code coverage in Xcode?. Right now I only see the bars:

enter image description here

I'll really appreciate your help.

like image 736
user2924482 Avatar asked Jul 25 '16 19:07

user2924482


People also ask

How is code coverage calculated in Xcode?

To collect code coverage data, run the test suite one more time. To see the code coverage report, open the Report Navigator on the left, select the report for the last test run, and open the Coverage tab at the top. You can see that Person. swift is completely covered by the unit tests we wrote.

What is code coverage percentage?

Code Coverage Percentage = (Number of lines of code executed by a testing algorithm/Total number of lines of code in a system component) * 100.

What is a good coverage percentage?

With that being said it is generally accepted that 80% coverage is a good goal to aim for. Trying to reach a higher coverage might turn out to be costly, while not necessary producing enough benefit. The first time you run your coverage tool you might find that you have a fairly low percentage of coverage.

How do I generate code coverage report in Xcode?

(View menu > Navigators > Reports or ⌘ - command + 9 ). After you open it, under the latest Test report, you should find a Coverage report, click on that, and it will contain the coverage information of that test run. You can find code coverage report under the Reports navigator.


1 Answers

Just some clarification on where to find these numbers in Xcode 10:

  1. Run your tests and navigate to the Test navigator
  2. Right click on the test and select "Jump to Report"

enter image description here

  1. Next to your target you should see "Test", right click on that, then select "Coverage" enter image description here
  2. Test Coverage info is then shown

enter image description here

like image 50
joshbillions Avatar answered Sep 28 '22 19:09

joshbillions