You want to check your UT index?
You want to display the coverage index on xcode to know if your code has reached the standard?
How to show Coverage index on xcode?
How to enable UT Coverage on XCode?
Those are the questions I get asked often, but there aren’t many tutorials on the internet yet. So today I will guide you to enable Code Coverage on Xcode
How to enable UT Coverage on Xcode 13.4.1 or below?
For projects using Xcode 13 or below to create, we do the following:
Step 1: Select Scheme -> edit Scheme -> a popup is displayed

Step 2: In the left menu of the popup select Test, then in the upper menu of the popup select option -> tick Code Coverage for

Step 3: Run test app (command + U)

How to enable UT Coverage on Xcode 14.0 or later?
For projects using Xcode 14 or later to create, we do the following:
Step 1: Select Scheme -> edit Scheme -> a popup is displayed

Step 2: In the left menu of Popup select Test, then hover on Test Plan as shown and then click the button to go to settings.

Step 3: Change code coverage to On

If you don’t need to test UI, you can remove the test plan for UI to make Unit tests run faster

Step 4: Run test (command + U), ta thu được kết quả như sau

I hope it can help!
Leave a Reply