Reporting Code Coverage testing
A useful tool in projects with code testing is to be able to analyze how much of a C# script class is being tested. For example, is every method being tested with at least one set of test data? Unity now offers a Code Coverage feature, which we’ll explore in this code-testing recipe. As shown in the following screenshot, Unity allows us to create a set of HTML pages for documenting the code coverage of tests against C# code.
With this, we can see what percentage of our code is covered by tests, and even which lines of code are, and are not, covered by our tests:
Figure 19.22: Code Coverage HTML report for the Player script class
Getting ready
This project builds on the previous one, so make a copy of what you made in that recipe and work on the copy.
How to do it...
To add Code Coverage reporting to a project with unit tests, follow these steps:
- Open the Code Coverage window by going to Window | Analysis...