1. What is Code Coverage (2 min)
Code Coverage is a measure of how much of your code has been executed. It is normally
associated with automated tests, but you can gather coverage data in Unity at any time when the
Editor is running.
It is typically presented as a report that shows the percentage of the code that has been executed.
For automated testing the report does not measure the quality of tests, only whether your code is
executed by PlayMode and EditMode tests. It is especially useful to check that critical or high risk
areas of your code are covered, because they should receive the most rigorous testing.
It is much easier to accidentally introduce bugs into code that is not covered by tests, because
those bugs are not detected straight away by the tests and can instead cause problems later —
such as after you have published your game or app.
Additionally, the Code Coverage package offers a Coverage Recording feature which allows
capturing coverage data on demand, in case you do not have tests in your project or doing manual
testing.
2. Install the Code Coverage package (2 min)
Skip this task if the package is already installed
Use the Unity Package Manager to find and install the Code Coverage package.
Alternatively, use the Add(+) dropdown and select Add package from git URL... or Add package by name... and
type com.unity.testtools.codecoverage