How to enable UT Coverage on Xcode?

by DaoNM2
10.1K views

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

How to enable UT Coverage on XCode

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.

How to enable UT Coverage on XCode

Step 3: Change code coverage to On

How to enable UT Coverage on XCode

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

How to enable UT Coverage on XCode

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

How to enable UT Coverage on XCode

I hope it can help!

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

You may also like