코드 커버리지란?
소프트웨어의 테스트를 논할 때 얼마나 테스트가 충분한가를 나타내는 지표중 하나다. 말 그대로 코드가 얼마나 커버되었는가이다. 소프트웨어 테스트를 진행했을 때 코드 자체가 얼마나 실행되었냐는 것이다.
( https://ko.wikipedia.org/wiki/%EC%BD%94%EB%93%9C_%EC%BB%A4%EB%B2%84%EB%A6%AC%EC%A7%80 )
코드 커버리지 - 위키백과, 우리 모두의 백과사전
ko.wikipedia.org
유니티 코드 커버리지는 실행된 코드의 양을 측정하고 보고서를 백분율로 보여준다.

코드 확인 안된 부분이 코드 단위로 확인이 가능하다

튜토리얼은 패키지 페이지에 워낙 잘 되어 있어서 직접 확인해보면 좋다
https://docs.unity3d.com/Packages/com.unity.testtools.codecoverage@1.1/manual/Quickstart.html
Quickstart - Code Coverage Tutorial | Code Coverage | 1.1.1
Quickstart - Code Coverage Tutorial The Quickstart guide will give you an insight into what Code Coverage is and how you can identify areas of your code that need more testing, even if you haven't written any automated tests. It takes about 30 minutes to c
docs.unity3d.com
2가지 방식으로 측정할 수 있다.
- 유닛테스트를 통해 측정하는 방법
- 런타임 플레이를 한 후 측정하는 방법
예외를 추가할 수 있다.
- [ExcludeFromCoverage], [ExcludeFromCodeCoverage] 어트리뷰트를 통해 커버리지에 포함되지 않게 할 수 있다.
- [Test, ConditionalIgnore] 어트리뷰트를 통해 코드 커버리지에 포함되지 않는 유닛 테스트를 만들 수 있다.
Batch mode로도 Code Coverage 실행이 가능
Generate Additional Metrics로 Cyclomatic Complexity를 측정 가능.
https://blog.seulgi.kim/2015/01/cyclomatic-complexity.html
Cyclomatic complexity - 코드의 복잡성을 정량적으로 측정하기
Cyclomatic complexity
blog.seulgi.kim
버스트 패키지를 사용하고 버스트로 컴파일된 작업이 있는경우 버스트 컴파일을 비활성화해야한다.
Code Coverage는 유니티 에디터의 성능에 영향을 줄 수 있으니 참고.
패키지 매뉴얼
Code Coverage window | Code Coverage | 1.1.1
Clear Data Select the Clear Data button to clear the coverage data from previous test runs or from previous Coverage Recording sessions. The Clear Data button is disabled if the coverage data is cleared, if no tests ran, or if there is no Coverage Recordin
docs.unity3d.com
CodeCoverage가 진행되는 동안 이벤트를 수신하여 커스터마이징 할 수 있다.
Class Events | Code Coverage | 1.1.1
Events invoked during a code coverage session. A code coverage session is the period between starting and finishing capturing code coverage data. Inheritance Events Assembly : solution.dll public static class Events : object In the following example we cre
docs.unity3d.com