test
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"timestamp": 1721946866,
|
||||
"signature": "a8ZWGbBWjwBRLFpk4wpreH8yFCSA9AAkBAAhIcKmAWD3Q/dN12SVR26Uh1UsT3f4+Df2LLn3hfUCS1EU8d9SIhBOvI0iC0Dcaw755vcgfe9MLCEgJs7UhELOpU0CL0yRmbM3XhO1AQKSOONoN9uhGpkREEsgKB8mMz2TmNYtfQg7kV2S1aB4kVsVVuSb6Be7Xmj9T+YhwcE74LxGjlxUuiXVHqyEzFZhmF5FHzYYtL6gC2TpNjuo+fRrOkUospKYn9agy0otVLLeq++j6OcYkfir+JvebCaL2DmwfUyQosubWNST+2s7bdv0fnI0uzxGDc/9/TuS1bVcGL+zLUtmR/Hl0U8GI36jOTC4IOHXuujsmGmkW7OtAKl06pAZ8lIgiecYMUS49Ih6XQUNa3sVexwFUlLS9FfTvJeCNVQB9E5zL0LxsUCIeRh8QZJ4PRrOHAtGHsZusXTyLpyl9dMBK5oUH6rkwy6Etl5o3c3lC236kJbb3Vt64tUq7viljSoI",
|
||||
"publicKey": "LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0KTUlJQm9qQU5CZ2txaGtpRzl3MEJBUUVGQUFPQ0FZOEFNSUlCaWdLQ0FZRUFzdUhXYUhsZ0I1cVF4ZEJjTlJKSAordHR4SmoxcVY1NTdvMlZaRE1XaXhYRVBkRTBEMVFkT1JIRXNSS1RscmplUXlERU83ZlNQS0ZwZ1A3MU5TTnJCCkFHM2NFSU45aHNQVDhOVmllZmdWem5QTkVMenFkVmdEbFhpb2VpUnV6OERKWFgvblpmU1JWKytwbk9ySTRibG4KS0twelJlNW14OTc1SjhxZ1FvRktKT0NNRlpHdkJMR2MxSzZZaEIzOHJFODZCZzgzbUovWjBEYkVmQjBxZm13cgo2ZDVFUXFsd0E5Y3JZT1YyV1VpWXprSnBLNmJZNzRZNmM1TmpBcEFKeGNiaTFOaDlRVEhUcU44N0ZtMDF0R1ZwCjVNd1pXSWZuYVRUemEvTGZLelR5U0pka0tldEZMVGdkYXpMYlpzUEE2aHBSK0FJRTJhc0tLTi84UUk1N3UzU2cKL2xyMnZKS1IvU2l5eEN1Q20vQWJkYnJMbXk0WjlSdm1jMGdpclA4T0lLQWxBRWZ2TzV5Z2hSKy8vd1RpTFlzUQp1SllDM0V2UE16ZGdKUzdGR2FscnFLZzlPTCsxVzROY05yNWdveVdSUUJ0cktKaWlTZEJVWmVxb0RvSUY5NHpCCndGbzJJT1JFdXFqcU51M3diMWZIM3p1dGdtalFra3IxVjJhd3hmcExLWlROQWdNQkFBRT0KLS0tLS1FTkQgUFVCTElDIEtFWS0tLS0tCg"
|
||||
}
|
@@ -0,0 +1,315 @@
|
||||
# Changelog
|
||||
All notable changes to the Code Coverage package will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
||||
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [1.2.6] - 2024-07-26
|
||||
|
||||
### Fixes
|
||||
- Documentation: Fixed formatting in [Using Code Coverage in batchmode](https://docs.unity3d.com/Packages/com.unity.testtools.codecoverage@1.2/manual/CoverageBatchmode.html) page (case [COV-40](https://issuetracker.unity3d.com/issues/docs-formatting-in-using-code-coverage-in-batchmode-docs-page-is-incorrect)).
|
||||
- Removed the references to the deprecated FindObjectOfType method in the *Asteroids sample project* (case [COV-42](https://issuetracker.unity3d.com/issues/sample-project-is-using-obsolete-findobjectoftype-method-which-causes-multiple-warnings-in-console-when-it-is-imported)).
|
||||
- Added missing logs for the ReportGenerator (case [COV-46](https://issuetracker.unity3d.com/issues/code-coverage-package-does-not-report-some-of-the-internal-reportgenerator-errors)).
|
||||
|
||||
## [1.2.5] - 2023-12-20
|
||||
|
||||
### Fixes
|
||||
- Fixed failing to generate code coverage for assemblies whose name starts with 'system' (case [COV-38](https://issuetracker.unity3d.com/issues/code-coverage-fails-to-generate-a-report-when-the-assembly-name-begins-with-the-word-system)).
|
||||
- Fixed results xml file not been correctly stored under the EditMode folder if it is written after a domain reload (case [COV-36](https://issuetracker.unity3d.com/issues/coverage-results-xml-file-is-not-categorized-as-editmode-if-it-is-written-after-domain-reload)).
|
||||
|
||||
## [1.2.4] - 2023-06-02
|
||||
|
||||
### Fixes
|
||||
- Fixed failing to gather code coverage for normal methods in generic classes (case [COV-27](https://issuetracker.unity3d.com/issues/non-generic-methods-in-generic-classes-always-show-no-coverage)).
|
||||
- Documentation: Corrected *Settings.json* path in `useProjectSettings` section in *-coverageOptions* (case [COV-26](https://issuetracker.unity3d.com/issues/documentation-for-useprojectsettings-references-incorrect-settings-dot-json-path)).
|
||||
- Make sure *Auto Generate Report* defaults to true when running from the command line (case [COV-25](https://issuetracker.unity3d.com/issues/useprojectsettings-does-not-generate-report-until-auto-generate-report-is-toggled-off-and-on-again)).
|
||||
|
||||
## [1.2.3] - 2023-04-14
|
||||
|
||||
### Fixes
|
||||
- Fixed failing to gather code coverage for generic methods (case [COV-17](https://issuetracker.unity3d.com/issues/coverage-package-fails-to-gather-any-coverage-for-generic-methods)).
|
||||
|
||||
### Improvements
|
||||
- Added `filtersFromFile` in *-coverageOptions* for [batchmode](https://docs.unity3d.com/Packages/com.unity.testtools.codecoverage@1.2/manual/CoverageBatchmode.html). This allows specifying an external Json file which contains path and assembly filtering rules. When this file contains relative paths, the `sourcePaths` option can be used to specify the source directories.
|
||||
<br/>**Note:** The `pathFiltersFromFile` option will be deprecated in the next package major release. Please use the new `filtersFromFile` option instead.
|
||||
- Make sure `--burst-disable-compilation` is [expected](https://docs.unity3d.com/Packages/com.unity.burst@latest/index.html?subfolder=/manual/getting-started.html#command-line-options) to be passed with two dashes, unlike other editor command line options.
|
||||
|
||||
## [1.2.2] - 2022-11-18
|
||||
|
||||
### Fixes
|
||||
- Temporary fix for the [Test Framework](https://docs.unity3d.com/Packages/com.unity.test-framework@latest/index.html) 1.3 issue where the *RunFinished* callback is not called when running from the command line and there is a domain reload (case [DSTR-692](https://issuetracker.unity3d.com/issues/registered-callbacks-dont-work-after-domain-reload)).
|
||||
|
||||
### Improvements
|
||||
- Reduced the number of logs for the default *Verbosity:Info*.
|
||||
- Added *Uncoverable lines* definition in [How to interpret the results](https://docs.unity3d.com/Packages/com.unity.testtools.codecoverage@1.2/manual/HowToInterpretResults.html#summary) page in the documentation.
|
||||
- Updated documentation to match version 1.2.2.
|
||||
|
||||
## [1.2.1] - 2022-10-27
|
||||
|
||||
### Fixes
|
||||
- Fixed compatibility with [Test Framework](https://docs.unity3d.com/Packages/com.unity.test-framework@latest/index.html) package version 1.3.
|
||||
|
||||
### Improvements
|
||||
- A single file summary version of the report is now generated in Json format, in addition to the XML and Markdown formats.
|
||||
- Added a warning when an invalid coverage option is passed in *-coverageOptions* in [batchmode](https://docs.unity3d.com/Packages/com.unity.testtools.codecoverage@1.2/manual/CoverageBatchmode.html).
|
||||
|
||||
## [1.2.0] - 2022-08-01
|
||||
|
||||
### Fixes
|
||||
- Ensure assemblies are removed from the Included Assemblies field if they no longer exist (case [1318668](https://issuetracker.unity3d.com/issues/code-coverage-the-included-assemblies-field-shows-assemblies-that-no-longer-exist)).
|
||||
- Ensure hidden sequence points are ignored (case [1372305](https://issuetracker.unity3d.com/issues/class-which-derives-from-methodbase-causes-incorrect-sequence-points-to-be-generated-by-coverage-api)).
|
||||
|
||||
### Changes
|
||||
- Updated Report Generator to version 5.0.4.
|
||||
- Updated the UI of the [Code Coverage window](https://docs.unity3d.com/Packages/com.unity.testtools.codecoverage@1.2/manual/CodeCoverageWindow.html) moving the action buttons into a toolbar at the top.
|
||||
- Renamed *assemblyFilters* aliases in [batchmode](https://docs.unity3d.com/Packages/com.unity.testtools.codecoverage@1.2/manual/CoverageBatchmode.html); `<user>` was renamed to `<assets>` and `<project>` was renamed to `<all>`.
|
||||
- Replaced `pathStrippingPatterns` with `pathReplacePatterns` in [batchmode](https://docs.unity3d.com/Packages/com.unity.testtools.codecoverage@1.2/manual/CoverageBatchmode.html). The `pathReplacePatterns` option allows stripping and replacing specific sections from the paths that are stored in the coverage results xml files.
|
||||
|
||||
See the [Upgrade guide](https://docs.unity3d.com/Packages/com.unity.testtools.codecoverage@1.2/manual/upgrade-guide.html) if upgrading to Code Coverage package version 1.2.
|
||||
|
||||
### Improvements
|
||||
- The size of the coverage result files and the Code Coverage session duration have been optimized. At the start of the session a coverage xml result file is generated which includes all the lines but with zero coverage. The following coverage xml result files that are generated within a Code Coverage session include only the coverage data of the visited lines.
|
||||
- Added Help IconButton in the toolbar in the [Code Coverage window](https://docs.unity3d.com/Packages/com.unity.testtools.codecoverage@1.2/manual/CodeCoverageWindow.html).
|
||||
- Updated the mechanic for opening the containing folder, change the location or reset to the default location for *Results Location* and *Report History Location*.
|
||||
- Refactored the [Code Coverage window](https://docs.unity3d.com/Packages/com.unity.testtools.codecoverage@1.2/manual/CodeCoverageWindow.html) UI to include a new *Report Options* section and removing the word 'Generate' from the options.
|
||||
- Introduced new selection buttons under the *Included Assemblies* dropdown in the [Code Coverage window](https://docs.unity3d.com/Packages/com.unity.testtools.codecoverage@1.2/manual/CodeCoverageWindow.html); use the *All* button to select all the assemblies in the project. Use the *Assets* button to select only the assemblies under the `Assets` folder. Use the *Packages* button to select only the Packages' assemblies. If searching, the buttons will apply only to the assemblies visible in the list.
|
||||
- Updated [What's new](https://docs.unity3d.com/Packages/com.unity.testtools.codecoverage@1.2/manual/whats-new.html) and [Upgrade guide](https://docs.unity3d.com/Packages/com.unity.testtools.codecoverage@1.2/manual/upgrade-guide.html) pages in the documentation.
|
||||
- Added [Using relative paths in path filters](https://docs.unity3d.com/Packages/com.unity.testtools.codecoverage@1.2/manual/CoverageBatchmode.html#using-relative-paths-in-path-filters) section in documentation.
|
||||
- Updated the editor and console logs; added information about the assembly and path filters, improved coverage session logs.
|
||||
- Improved the progress bars for `Writing coverage results` and `Generating the report`.
|
||||
- Added an icon for the [Code Coverage window](https://docs.unity3d.com/Packages/com.unity.testtools.codecoverage@1.2/manual/CodeCoverageWindow.html).
|
||||
- Updated documentation to match version 1.2.0.
|
||||
|
||||
### Features
|
||||
- Added `Pause Recording` and `Resume Recording` buttons in the toolbar in the [Code Coverage window](https://docs.unity3d.com/Packages/com.unity.testtools.codecoverage@1.2/manual/CodeCoverageWindow.html).
|
||||
- Added `Log Verbosity Level` setting in the [Code Coverage window](https://docs.unity3d.com/Packages/com.unity.testtools.codecoverage@1.2/manual/CodeCoverageWindow.html) which allows setting the verbosity level for the editor and console logs.
|
||||
- Added `Additional Reports` option in the [Code Coverage window](https://docs.unity3d.com/Packages/com.unity.testtools.codecoverage@1.2/manual/CodeCoverageWindow.html) which if checked [SonarQube](https://docs.sonarqube.org/latest/analysis/generic-test), [Cobertura](https://cobertura.github.io/cobertura) and [LCOV](https://github.com/linux-test-project/lcov) reports will be generated. Added `generateAdditionalReports` in *-coverageOptions* for [batchmode](https://docs.unity3d.com/Packages/com.unity.testtools.codecoverage@1.2/manual/CoverageBatchmode.html).
|
||||
- Added `Test Runner References` report option in the [Code Coverage window](https://docs.unity3d.com/Packages/com.unity.testtools.codecoverage@1.2/manual/CodeCoverageWindow.html) which if checked includes test references to the generated coverage results and enables the [Coverage by test methods](https://docs.unity3d.com/Packages/com.unity.testtools.codecoverage@1.2/manual/HowToInterpretResults.html#coverage-by-test-methods) section in the HTML report, allowing you to see how each test contributes to the overall coverage. Added `generateTestReferences` in *-coverageOptions* for [batchmode](https://docs.unity3d.com/Packages/com.unity.testtools.codecoverage@1.2/manual/CoverageBatchmode.html).
|
||||
- Added `Auto Open Report` option in the [Code Coverage window](https://docs.unity3d.com/Packages/com.unity.testtools.codecoverage@1.2/manual/CodeCoverageWindow.html) which if checked the coverage report will open automatically after it has been generated.
|
||||
- Added `pathFiltersFromFile` in *-coverageOptions* for [batchmode](https://docs.unity3d.com/Packages/com.unity.testtools.codecoverage@1.2/manual/CoverageBatchmode.html) which allows specifying an external file which contains a list of path filters. When this file contains relative paths, the `sourcePaths` option can be used to specify the source directories.
|
||||
- Added `dontClear` in *-coverageOptions* for [batchmode](https://docs.unity3d.com/Packages/com.unity.testtools.codecoverage@1.2/manual/CoverageBatchmode.html) which allows coverage results to be accumulated after every code coverage session. If not passed the results are cleared before a new session. For more information see [Generate combined report from EditMode and PlayMode tests](https://docs.unity3d.com/Packages/com.unity.testtools.codecoverage@1.2/manual/CoverageBatchmode.html#generate-combined-report-from-editmode-and-playmode-tests).
|
||||
- When the `pathFilters` option or the `pathFiltersFromFile` option in *-coverageOptions* contains relative paths, the `sourcePaths` option can be used to specify the source directories.
|
||||
|
||||
## [1.1.1] - 2021-12-17
|
||||
|
||||
### Fixes
|
||||
- Ensure assemblies are removed from the Included Assemblies field if they no longer exist (case [1318668](https://issuetracker.unity3d.com/issues/code-coverage-the-included-assemblies-field-shows-assemblies-that-no-longer-exist))
|
||||
|
||||
### Changes
|
||||
- Updated Report Generator to version 4.8.13
|
||||
|
||||
### Improvements
|
||||
- Added Help IconButton in the [Code Coverage window](https://docs.unity3d.com/Packages/com.unity.testtools.codecoverage@1.1/manual/CodeCoverageWindow.html) for Unity versions 2021.2.2f1 and above
|
||||
- Added [What's new](https://docs.unity3d.com/Packages/com.unity.testtools.codecoverage@1.1/manual/whats-new.html) and [Upgrade guide](https://docs.unity3d.com/Packages/com.unity.testtools.codecoverage@1.1/manual/upgrade-guide.html) pages in the documentation
|
||||
- Updated documentation to match version 1.1.1
|
||||
|
||||
|
||||
## [1.1.0] - 2021-06-09
|
||||
|
||||
### Fixes
|
||||
- Ensure Results and History folders are created if they do not exist (case [1334551](https://issuetracker.unity3d.com/issues/code-coverage-results-slash-history-location-path-is-reset-to-default-if-set-path-no-longer-exists))
|
||||
- Added support for [ExcludeFromCoverage/ExcludeFromCodeCoverage](https://docs.unity3d.com/Packages/com.unity.testtools.codecoverage@1.0/manual/UsingCodeCoverage.html#excluding-code-from-code-coverage) for lambda expressions and yield statements (case [1338636](https://issuetracker.unity3d.com/issues/code-coverage-excludefromcoverage-attribute-doesnt-exclude-lambda-expressions-and-yield-statements-from-coverage))
|
||||
- Added support for [ExcludeFromCodeCoverage](https://docs.unity3d.com/Packages/com.unity.testtools.codecoverage@1.0/manual/UsingCodeCoverage.html#excluding-code-from-code-coverage) for getter/setter properties (case [1338665](https://issuetracker.unity3d.com/issues/code-coverage-get-and-set-accessors-are-still-marked-as-coverable-when-property-has-excludefromcodecoverage-attribute))
|
||||
- *-coverageOptions* are only parsed when running from the command line ([feedback](https://forum.unity.com/threads/code-coverage-slowing-editor-on-enter-playmode-and-assembly-reload.1121566))
|
||||
|
||||
### Changes
|
||||
- Updated Report Generator to version 4.8.9
|
||||
|
||||
### Improvements
|
||||
- Implemented changes to support [Test Framework](https://docs.unity3d.com/Packages/com.unity.test-framework@latest/index.html) package version 1.2
|
||||
- Logs while the Report is generated are output per message rather than at the end of the generation
|
||||
- Do not log burst warning when `--burst-disable-compilation` is passed in the command line
|
||||
- Added [Ignoring tests for Code Coverage](https://docs.unity3d.com/Packages/com.unity.testtools.codecoverage@1.1/manual/CoverageBatchmode.html#ignoring-tests-for-code-coverage) section in documentation
|
||||
- Updated the [Generate combined report from separate projects](https://docs.unity3d.com/Packages/com.unity.testtools.codecoverage@1.1/manual/CoverageBatchmode.html#generate-combined-report-from-separate-projects) section in documentation
|
||||
- Updated documentation to match version 1.1.0
|
||||
|
||||
### Features
|
||||
- Added `Code Coverage session Events` [API](https://docs.unity3d.com/Packages/com.unity.testtools.codecoverage@1.1/api/UnityEditor.TestTools.CodeCoverage.Events.html) to subscribe to events invoked during a Code Coverage session
|
||||
- Added `useProjectSettings` in *-coverageOptions* for [batchmode](https://docs.unity3d.com/Packages/com.unity.testtools.codecoverage@1.1/manual/CoverageBatchmode.html) which allows using the settings specified in `ProjectSettings/Settings.json`
|
||||
- Added `pathStrippingPatterns` in *-coverageOptions* for [batchmode](https://docs.unity3d.com/Packages/com.unity.testtools.codecoverage@1.1/manual/CoverageBatchmode.html) which allows stripping specific sections from the paths that are stored in the coverage results xml files
|
||||
- Added `sourcePaths` in *-coverageOptions* for [batchmode](https://docs.unity3d.com/Packages/com.unity.testtools.codecoverage@1.1/manual/CoverageBatchmode.html) which allows specifying the source directories which contain the corresponding source code
|
||||
|
||||
## [1.0.0] - 2021-03-09
|
||||
|
||||
### Fixes
|
||||
- Fixed issues with Path Filtering (cases [1318896](https://issuetracker.unity3d.com/issues/code-coverage-typing-comma-into-the-included-or-excluded-paths-list-will-start-adding-row-for-each-letter-you-type-afterwards), [1318897](https://issuetracker.unity3d.com/issues/code-coverage-clearing-last-included-paths-row-immediatly-jumps-to-the-first-excluded-paths-row-and-starts-editing-it))
|
||||
|
||||
### Improvements
|
||||
- Selection/focus is cleared when mouse is clicked outside of the individual settings' areas
|
||||
- Added [Quickstart guide](https://docs.unity3d.com/Packages/com.unity.testtools.codecoverage@1.0/manual/Quickstart.html) in documentation
|
||||
- Renamed the *Code Coverage Workshop* sample to *Code Coverage Tutorial*
|
||||
- Updated documentation and workshop to match version 1.0.0
|
||||
|
||||
**Note:** In Unity 2019 and 2020 you can enable Code Coverage in [General Preferences](https://docs.unity3d.com/Manual/Preferences.html). This was removed in Unity 2021; the user interface for managing Code Coverage is now entirely inside the Code Coverage package.
|
||||
|
||||
## [1.0.0-pre.4] - 2021-02-26
|
||||
|
||||
### Fixes
|
||||
- Fixed assembly version validation error due to internal libraries included in the ReportGeneratorMerged.dll (case [1312121](https://issuetracker.unity3d.com/issues/code-coverage-reportgeneratormerged-cant-be-loaded-due-to-assembly-version-validation-failure))
|
||||
|
||||
### Changes
|
||||
- Added *Enable Code Coverage* checkbox under Settings in [Code Coverage window](https://docs.unity3d.com/Packages/com.unity.testtools.codecoverage@1.0/manual/CodeCoverageWindow.html).<br/>**Note:** In Unity 2019 and 2020 you can enable Code Coverage in [General Preferences](https://docs.unity3d.com/Manual/Preferences.html). This was removed in Unity 2021; the user interface for managing Code Coverage is now entirely inside the Code Coverage package.
|
||||
- The settings and options passed in the command line override/disable the settings in the Code Coverage window and relevant warnings display to indicate this
|
||||
- Updated Report Generator to version 4.8.5
|
||||
- Updated documentation and workshop to match version 1.0.0-pre.4
|
||||
|
||||
### Improvements
|
||||
- Added `verbosity` in *-coverageOptions* for [batchmode](https://docs.unity3d.com/Packages/com.unity.testtools.codecoverage@1.0/manual/CoverageBatchmode.html)
|
||||
- Added *Generate combined report from separate projects* section in documentation, under [Using Code Coverage in batchmode](https://docs.unity3d.com/Packages/com.unity.testtools.codecoverage@1.0/manual/CoverageBatchmode.html#generate-combined-report-from-separate-projects)
|
||||
|
||||
## [1.0.0-pre.3] - 2021-01-21
|
||||
|
||||
### Fixes
|
||||
- Updated Include Platforms to Editor only in the ReportGeneratorMerged.dll settings. Fixes an Android build error introduced in 1.0.0-pre.2 (case 1306557)
|
||||
|
||||
## [1.0.0-pre.2] - 2021-01-13
|
||||
|
||||
### Fixes
|
||||
- Fixed multiple reports generated in batchmode when passing `generateHtmlReport` in *-coverageOptions* without passing `-runTests`
|
||||
|
||||
### Changes
|
||||
- All project assemblies are included when there are included paths specified in *pathFilters* but no included assemblies in *assemblyFilters*, when running in batchmode
|
||||
- Updated Report Generator to version 4.8.4
|
||||
- Updated documentation to match version 1.0.0-pre.2
|
||||
|
||||
### Improvements
|
||||
- Introduced new *assemblyFilters* aliases in [batchmode](https://docs.unity3d.com/Packages/com.unity.testtools.codecoverage@1.0/manual/CoverageBatchmode.html), used for referencing a group of assemblies to include or exclude. These are `<user>`, `<project>` and `<packages>`
|
||||
|
||||
## [1.0.0-pre.1] - 2020-11-12
|
||||
- *1.0.0-pre.1* matches *0.4.0-preview*
|
||||
|
||||
## [0.4.0-preview] - 2020-11-11
|
||||
|
||||
### Changes
|
||||
- Moved Code Coverage window under *Window* > *Analysis*
|
||||
- *Included Assemblies* now use a single dropdown instead of an editable text field which acted as a dropdown
|
||||
- Added CommandLineParser and removed dependency to internals in Test Framework
|
||||
- Removed the old *EditorPref* workflow from CoveragePreferences
|
||||
- Moved *Generate History* outside of *Generate HTML Report*. It is now disabled only if both *Generate HTML Report* and *Generate Badges* are not selected
|
||||
- Updated Report Generator to version 4.7.1
|
||||
- Updated documentation and workshop to match version 0.4.0-preview
|
||||
|
||||
### Improvements
|
||||
- Implemented `{ProjectPath}` alias in `Settings.json`
|
||||
- Added a console warning when *Burst Compilation* is enabled and an info HelpBox with a button to disable
|
||||
- Added Analytics to help improve the user experience
|
||||
- Disabled *Generate from Last* button when there are no assemblies selected
|
||||
- Display an info HelpBox when there are no assemblies selected
|
||||
- Paths are now stored with forward slashes on Windows
|
||||
- Added warning about Code Coverage not being supported currently when running PlayMode tests in standalone player
|
||||
- Refactored code; in Utils, Filtering, ResultWriter, Window and API classes
|
||||
- Added *CoverageWindow* and *Filtering* folders
|
||||
|
||||
### Features
|
||||
- Added *Included Paths* and *Excluded Paths* as ReorderableLists in the [Code Coverage window](https://docs.unity3d.com/Packages/com.unity.testtools.codecoverage@0.4/manual/CodeCoverageWindow.html)
|
||||
- Added [support](https://docs.unity3d.com/Packages/com.unity.testtools.codecoverage@0.4/manual/UsingCodeCoverage.html#excluding-code-from-code-coverage) for `ExcludeFromCoverage` and `ExcludeFromCodeCoverage` attributes
|
||||
- Added `CodeCoverage.VerbosityLevel` [API](https://docs.unity3d.com/Packages/com.unity.testtools.codecoverage@0.4/api/UnityEditor.TestTools.CodeCoverage.CodeCoverage.html) to set the verbosity level used in editor and console logs
|
||||
|
||||
## [0.3.1-preview] - 2020-08-03
|
||||
|
||||
### Fixes
|
||||
- Fixed issue where CRAP calculation was incorrect when generic methods were parsed
|
||||
- Corrected Six Labors License copyright in Third Party Notices
|
||||
|
||||
### Changes
|
||||
- If `assemblyFilters` is not specified in *-coverageOptions* in batchmode, include only the assemblies found under the *Assets* folder
|
||||
- Updated Report Generator to version 4.6.4
|
||||
|
||||
## [0.3.0-preview] - 2020-05-20
|
||||
|
||||
### Fixes
|
||||
- Make sure *operator* and *anonymous function* names are generated correctly
|
||||
|
||||
### Changes
|
||||
- Added *Generate Additional Metrics* setting in the [Code Coverage window](https://docs.unity3d.com/Packages/com.unity.testtools.codecoverage@0.3/manual/CodeCoverageWindow.html) and removed *Cyclomatic Complexity* (it is now included in Additional Metrics)
|
||||
- Updated Report Generator to version 4.5.8
|
||||
- Updated documentation to match version 0.3.0-preview
|
||||
|
||||
### Improvements
|
||||
- Added [Code Coverage Workshop](https://docs.unity3d.com/Packages/com.unity.testtools.codecoverage@0.3/manual/CodeCoverageWorkshop.html) sample project
|
||||
- Using the [Settings Manager](https://docs.unity3d.com/Manual/com.unity.settings-manager.html) package to handle the serialization of project settings
|
||||
- Added an info HelpBox when *Code Optimization* is set to Release mode with a button to switch to Debug mode
|
||||
- Execute *Stop Recording* on the update loop, instead of the OnGUI (removes an *EndLayoutGroup* error)
|
||||
- Refactored code; in OpenCoverReporter class (to reduce Cyclomatic Complexity), in CodeCoverageWindow class and others
|
||||
|
||||
### Features
|
||||
- Added *History Location* and *Generate History* settings in the [Code Coverage window](https://docs.unity3d.com/Packages/com.unity.testtools.codecoverage@0.3/manual/CodeCoverageWindow.html)
|
||||
- Added `coverageHistoryPath` and `generateHtmlReportHistory` in *-coverageOptions* for [batchmode](https://docs.unity3d.com/Packages/com.unity.testtools.codecoverage@0.3/manual/UsingCodeCoverage.html#using-code-coverage-in-batchmode)
|
||||
- Added `generateAdditionalMetrics` in *-coverageOptions* for [batchmode](https://docs.unity3d.com/Packages/com.unity.testtools.codecoverage@0.3/manual/UsingCodeCoverage.html#using-code-coverage-in-batchmode) and removed *enableCyclomaticComplexity* (it is now included in Additional Metrics)
|
||||
- Added *Crap Score* in Additional Metrics. See [How to interpret the results](https://docs.unity3d.com/Packages/com.unity.testtools.codecoverage@0.3/manual/HowToInterpretResults.html).
|
||||
|
||||
## [0.2.3-preview] - 2020-02-18
|
||||
|
||||
### Fixes
|
||||
- *Included Assemblies* dropdown is now resizing to the longest assembly name ([1215600](https://issuetracker.unity3d.com/issues/there-is-no-way-to-view-the-full-name-of-an-assembly-when-selecting-it-in-a-small-code-coverage-window))
|
||||
- When closing (selecting outside of) the *Included Assemblies* dropdown, input is not accidentally propagated to the Code Coverage window
|
||||
|
||||
### Improvements
|
||||
- If more than one instance of the *-coverageOptions* command-line argument is specified, they will now be merged into a single instance
|
||||
- If more than one instance of the *-coverageResultsPath* command-line argument is specified, only the first instance will be accepted
|
||||
- Added *Generate combined report from EditMode and PlayMode tests* section in documentation, under [Using Code Coverage in batchmode](https://docs.unity3d.com/Packages/com.unity.testtools.codecoverage@0.2/manual/UsingCodeCoverage.html#using-code-coverage-in-batchmode)
|
||||
|
||||
## [0.2.2-preview] - 2019-12-11
|
||||
|
||||
### Fixes
|
||||
- Fixed unassigned *CodeCoverageWindow.m_IncludeWarnings* warning in 2019.3
|
||||
|
||||
### Changes
|
||||
- The default *Included Assemblies* are now only the assemblies found under the project's *Assets* folder, instead of all project assemblies
|
||||
|
||||
### Improvements
|
||||
- After the report is generated, the file viewer window highlights the `index.htm` file, if *Generate HTML Report* is selected
|
||||
|
||||
## [0.2.1-preview] - 2019-12-04
|
||||
|
||||
### Improvements
|
||||
- Improved globbing for `pathFilters` and `assemblyFilters`
|
||||
- Added new sections and examples in documentation
|
||||
- Added confirmation dialogs when selecting *Clear Data* and *Clear History* buttons
|
||||
- Added warning and button to switch to debug mode, when using Code Optimization in release mode in 2020.1 and above
|
||||
|
||||
### Features
|
||||
- Added `pathFilters` in *-coverageOptions* for [batchmode](https://docs.unity3d.com/Packages/com.unity.testtools.codecoverage@0.2/manual/UsingCodeCoverage.html#using-code-coverage-in-batchmode)
|
||||
|
||||
## [0.2.0-preview] - 2019-11-13
|
||||
|
||||
### Fixes
|
||||
- Make sure recording coverage results are saved in the *Recording* folder, and starting a new recording session does not affect existing non-recording data
|
||||
|
||||
### Changes
|
||||
- Updated Report Generator to version 4.3.6
|
||||
- Split documentation into separate pages
|
||||
|
||||
### Improvements
|
||||
- Updated UX design of the Code Coverage window
|
||||
- Make sure settings and Record button are disabled when coverage is running
|
||||
- Make sure coverage window is disabled before unity is restarted when *Enabling Code Coverage* in Preferences
|
||||
- Only parse xml files with the correct filename format when generating the report
|
||||
- Implemented try/catch when deleting files/folders when selecting *Clear Data* or *Clear History*
|
||||
- Handle nested classes, nested generic classes and anonymous functions
|
||||
|
||||
### Features
|
||||
- Exposed `CodeCoverage.StartRecording()`, `CodeCoverage.StopRecording()`, `CodeCoverage.PauseRecording()` and `CodeCoverage.UnpauseRecording()` [API](https://docs.unity3d.com/Packages/com.unity.testtools.codecoverage@0.2/api/UnityEditor.TestTools.CodeCoverage.CodeCoverage.html)
|
||||
|
||||
## [0.1.0-preview.3] - 2019-09-27
|
||||
|
||||
### Improvements
|
||||
- Passing `-coverageOptions generateHtmlReport` on the command line now creates a report if `-runTests` is not passed
|
||||
|
||||
## [0.1.0-preview.2] - 2019-09-23
|
||||
|
||||
### Changes
|
||||
- Updated Report Generator to version 4.2.20
|
||||
|
||||
### Improvements
|
||||
- Added support for correct naming of c# operators
|
||||
- Added support for correct naming of constructors
|
||||
- Added declaring type name as a prefix
|
||||
- Added support for return types in method names
|
||||
|
||||
### Features
|
||||
- Added [Coverage Recording](https://docs.unity3d.com/Packages/com.unity.testtools.codecoverage@0.2/manual/CoverageRecording.html) feature
|
||||
|
||||
## [0.1.0-preview.0] - 2019-03-18
|
||||
|
||||
### This is the first release of *Code Coverage Package*
|
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a6351153cf5e1af468cae5dbc72d1a04
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,29 @@
|
||||
# Code Coverage window
|
||||
|
||||

|
||||
|
||||
|**Toolbar**|**Description**|
|
||||
|:---|:---|
|
||||
||Select **Start Recording** to start recording code coverage data and **Stop Recording** to stop recording.|
|
||||
||Select **Pause Recording** to pause recording code coverage data and **Resume Recording** to resume recording. The buttons are disabled if not in a [Coverage Recording](CoverageRecording.md) session.|
|
||||
|Generate Report|Select **Generate Report** to generate a coverage report from the last set of tests that were run in the [Test Runner](CoverageTestRunner.md) or from the last [Coverage Recording](CoverageRecording.md) session. Note that **Generate Report** is disabled if no tests ran, there is no Coverage Recording data or all **HTML Report**, **Additional Reports** and **Summary Badges** checkboxes are unchecked.|
|
||||
|Clear Results|Select **Clear Results** to clear the coverage data from previous test runs or from previous [Coverage Recording](CoverageRecording.md) sessions. **Clear Results** is disabled if the coverage results are cleared, if no tests ran, or if there is no Coverage Recording data.|
|
||||
|Clear History|Select **Clear History** to clear the coverage report history. **Clear History** is disabled if the history is cleared or if no reports were generated.|
|
||||
||Select **Help** to open the Documentation Reference for Code Coverage in the web browser.|
|
||||
|**Settings**|**Description**|
|
||||
|Enable Code Coverage|Check this to enable Code Coverage. This is required in order to generate Coverage data and reports. Note that Code Coverage can affect the Editor performance.|
|
||||
|Results Location|Select the dropdown to open or specify the folder where the coverage results and report are saved to, and to reset to the default location. The default location is the Project's folder.|
|
||||
|Report History Location|Select the dropdown to open or specify the folder where the coverage report history is saved to, and to reset to the default location. The default location is the Project's folder.|
|
||||
|Included Assemblies|Specify assemblies to be included in the coverage results. This is a dropdown list containing the available assemblies. Click the dropdown to view, select or deselect the assemblies. Select **All** to select all the assemblies in the project. Select **Assets** to select only the assemblies under the `Assets` folder. Select **Packages** to select only the Packages' assemblies. Select **Deselect All** to deselect all the assemblies.</br></br>**Note:** If searching, the buttons will apply only to the assemblies visible in the list.|
|
||||
|Included Paths|Select **Add (+)** to specify individual folders and files to include in coverage results. You can use globbing to filter the paths. If the list is empty, Unity includes all files in the **Included Assemblies**. To remove an individual list entry, select the entry and then select **Remove (-)**.|
|
||||
|Excluded Paths|Select **Add (+)** to specify individual folders and files to exclude from coverage results. You can use globbing to filter the paths. To remove an individual list entry, select the entry and then select **Remove (-)**.|
|
||||
|Log Verbosity Level|Click the dropdown to set the verbosity level for the editor and console logs. The default level is `Info`.<br/><br/>**Levels:**<br/>`Verbose` All logs will be printed.<br/>`Info` Logs, Warnings and Errors will be printed.<br/>`Warning` Warnings and Errors will be printed.<br/>`Error` Only Errors will be printed.<br/>`Off` No logs will be printed.|
|
||||
|**Report Options**|**Description**|
|
||||
|HTML Report|Check this to generate an [HTML report](HowToInterpretResults.md).|
|
||||
|Additional Reports|Check this to generate [SonarQube](https://docs.sonarqube.org/latest/analysis/generic-test), [Cobertura](https://cobertura.github.io/cobertura) and [LCOV](https://github.com/linux-test-project/lcov) reports.|
|
||||
|Report History|Check this to generate and include the coverage history in the HTML report.|
|
||||
|Summary Badges|Check this to generate coverage summary badges in SVG and PNG format.|
|
||||
|Additional Metrics|Check this to generate and include additional metrics in the HTML report. These currently include Cyclomatic Complexity and Crap Score calculations for each method. See the [Risk Hotspots](HowToInterpretResults.md#risk-hotspots) section for more information.|
|
||||
|Test Runner References|Check this to include test references to the generated coverage results and enable the [Coverage by test methods](HowToInterpretResults.md#coverage-by-test-methods) section in the HTML report. This shows how each test contributes to the overall coverage.|
|
||||
|Auto Generate Report|Check this to generate the report automatically after the [Test Runner](CoverageTestRunner.md) finishes running or the [Coverage Recording](CoverageRecording.md) session is complete.|
|
||||
|Auto Open Report|Check this to open the coverage report automatically after it has been generated.|
|
@@ -0,0 +1,34 @@
|
||||
# On-demand coverage recording
|
||||
|
||||
With Coverage Recording you can capture coverage data on demand and generate an [HTML report](HowToInterpretResults.md) which shows which lines of your code run while recording. It supports capturing in EditMode as well as in PlayMode, and you can switch between the two.
|
||||
|
||||
To start recording coverage data, select **Start Recording**. While recording, use the Editor as usual, for example to enter PlayMode. To stop recording coverage data, select **Stop Recording**. If **Auto Generate Report** is checked, then an [HTML report](HowToInterpretResults.md) is generated and a file viewer window opens (if **Auto Open Report** is checked too). It contains the coverage results and the report. Otherwise, select **Generate Report** to generate the report. The results are based on the assemblies specified in **Included Assemblies**.
|
||||
|
||||
You can also control Coverage Recording via the [CodeCoverage ScriptingAPI](https://docs.unity3d.com/Packages/com.unity.testtools.codecoverage@latest/index.html?subfolder=/api/UnityEditor.TestTools.CodeCoverage.CodeCoverage.html).
|
||||
|
||||
## Steps
|
||||
|
||||
1. Open the [Code Coverage window](CodeCoverageWindow.md) (go to **Window** > **Analysis** > **Code Coverage**).<br/><br/>
|
||||

|
||||
|
||||
2. Select **Enable Code Coverage** if not already selected, to be able to generate Coverage data and reports.<br/>
|
||||
<br/>**Note:** Enabling Code Coverage adds some overhead to the Editor and can affect the performance.
|
||||
|
||||
3. Select the [Assembly Definitions](https://docs.unity3d.com/Manual/ScriptCompilationAssemblyDefinitionFiles.html) you would like to see the coverage for. In this example we selected `Assembly-CSharp` and `Assembly-CSharp-Editor`. By default, Unity compiles almost all project scripts into the `Assembly-CSharp.dll` managed assembly and all Editor scripts into the `Assembly-CSharp-Editor.dll` managed assembly.<br/><br/>
|
||||

|
||||
|
||||
4. Select **Start Recording**.<br/>
|
||||

|
||||
|
||||
5. Continue using the Editor as normal, for example enter PlayMode to test your application or run some manual testing. You can also select **Pause Recording** to pause recording and **Resume Recording** to resume recording.
|
||||
|
||||
6. When you have finished your testing and have collected enough coverage data, select **Stop Recording**.<br/>
|
||||

|
||||
|
||||
7. If **Auto Open Report** is checked a file viewer window opens containing the coverage report. Alternatively, select the **Results Location** dropdown to open it in the file viewer.<br/><br/>**Note:** To generate the report automatically after you stop recording, select **Auto Generate Report** in the [Code Coverage window](CodeCoverageWindow.md). Alternatively, you can select **Generate Report**.<br/>
|
||||
|
||||
8. Select `index.htm`.<br/><br/>
|
||||

|
||||
|
||||
9. This opens the [HTML coverage report](HowToInterpretResults.md).<br/><br/>
|
||||

|
@@ -0,0 +1,55 @@
|
||||
# Using Code Coverage with Test Runner
|
||||
|
||||
When running your tests in the [Test Runner](https://docs.unity3d.com/Packages/com.unity.test-framework@latest/index.html?subfolder=/manual/workflow-run-test.html) you can generate an [HTML report](HowToInterpretResults.md) which shows which lines of your code the tests cover. This includes both `EditMode` and `PlayMode` tests.
|
||||
|
||||
If **Auto Generate Report** is checked, then an [HTML report](HowToInterpretResults.md) is generated and a file viewer window opens (if **Auto Open Report** is checked too). It contains the coverage results and the report. Otherwise, select **Generate Report** to generate the report. The results are based on the assemblies specified in **Included Assemblies**.
|
||||
|
||||
## Steps
|
||||
|
||||
1. Open the [Code Coverage window](CodeCoverageWindow.md) (go to **Window** > **Analysis** > **Code Coverage**).<br/><br/>
|
||||

|
||||
|
||||
2. Select **Enable Code Coverage** if not already selected, to be able to generate Coverage data and reports.<br/>
|
||||
<br/>**Note:** Enabling Code Coverage adds some overhead to the Editor and can affect the performance.
|
||||
|
||||
3. Select the [Assembly Definitions](https://docs.unity3d.com/Manual/ScriptCompilationAssemblyDefinitionFiles.html) you would like to see the coverage for. In this example we selected `Assembly-CSharp` and `Assembly-CSharp-Editor`. By default, Unity compiles almost all project scripts into the `Assembly-CSharp.dll` managed assembly and all Editor scripts into the `Assembly-CSharp-Editor.dll` managed assembly.<br/><br/>
|
||||

|
||||
|
||||
4. Switch to the [Test Runner](https://docs.unity3d.com/Packages/com.unity.test-framework@latest/index.html?subfolder=/manual/workflow-run-test.html) and run your `EditMode` and/or `PlayMode` test(s).<br/><br/>
|
||||

|
||||
|
||||
Example test:
|
||||
```
|
||||
using NUnit.Framework;
|
||||
using Assert = UnityEngine.Assertions.Assert;
|
||||
|
||||
public class EditorTests
|
||||
{
|
||||
[Test]
|
||||
public void MyPublicClass_PublicFunctionCanBeCalled()
|
||||
{
|
||||
MyPublicClass myPublicClass = new MyPublicClass();
|
||||
Assert.IsTrue(myPublicClass.MyPublicFunction());
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
5. When the test(s) finish running, a file viewer window opens containing the coverage report. Alternatively, select the **Results Location** dropdown to open it in the file viewer.<br/><br/>**Note:** To generate the report automatically after the Test Runner has finished running the tests, select **Auto Generate Report** in the [Code Coverage window](CodeCoverageWindow.md). Alternatively, you can select **Generate Report**.<br/>
|
||||
|
||||
6. Select `index.htm`.<br/><br/>
|
||||

|
||||
<br/><br/>
|
||||
This opens the [HTML coverage report](HowToInterpretResults.md).<br/><br/>
|
||||

|
||||
<br/>
|
||||
|
||||
## Get results for EditMode and PlayMode tests
|
||||
|
||||
Coverage data are generated from the last set of tests that were run in the [Test Runner](https://docs.unity3d.com/Packages/com.unity.test-framework@latest/index.html?subfolder=/manual/workflow-run-test.html).<br/><br/>
|
||||
**Note:** Currently the [Test Runner](https://docs.unity3d.com/Packages/com.unity.test-framework@latest/index.html?subfolder=/manual/workflow-run-test.html) does not support `EditMode` and `PlayMode` tests running at the same time. In [version 2.0](https://docs.unity3d.com/Packages/com.unity.test-framework@2.0/manual/whats-new.html#added) of the Test Framework this will be possible. In the meantime, to include coverage for both `EditMode` and `PlayMode` tests, you must run these separately. In this case, the last Coverage Report generated will include the combined coverage of `EditMode` and `PlayMode` tests.
|
||||
|
||||
If a fresh start is required, select **Clear Results** to clear the Coverage data from all previous test runs for both `EditMode` and `PlayMode` tests.
|
||||
|
||||
## Get coverage by test methods
|
||||
|
||||
To see how each test contributes to the overall coverage check **Test Runner References**. For more details see [Coverage by test methods](HowToInterpretResults.md#coverage-by-test-methods).
|
@@ -0,0 +1,21 @@
|
||||
# Document revision history - Archive
|
||||
|
||||
|Date|Reason|
|
||||
|:---|:---|
|
||||
|Feb 26, 2021|<li>Added information about the *Enable Code Coverage* setting in the Code Coverage window<li>Updated *Installing Code Coverage* section<li>Added *verbosity* section in *-coverageOptions*<li>Added *Generate combined report from separate projects* section<li>Matches package version *1.0.0-pre.4*|
|
||||
|Jan 13, 2021|<li>Added information about *assemblyFilters* aliases and note about how *path filtering* can take precedence over *assembly filtering* in *Using Code Coverage in batchmode* section<li>Matches package version *1.0.0-pre.2*|
|
||||
|Nov 12, 2020|<li>Matches package version *1.0.0-pre.1*|
|
||||
|Nov 11, 2020|<li>Added information about *Included Paths* and *Excluded Paths* settings in the Code Coverage window<li>Updated information about *Included Assemblies* setting in the Code Coverage window<li>Matches package version *0.4.0-preview*|
|
||||
|Aug 3, 2020|<li>Matches package version *0.3.1-preview*|
|
||||
|May 20, 2020|<li>Added information about the *History Location* and *Generate History* settings in the Code Coverage window and *coverageHistoryPath* and *generateHtmlReportHistory* in *-coverageOptions*<li>Added information about the *Generate Additional Metrics* setting in the Code Coverage window and *generateAdditionalMetrics* in *-coverageOptions*<li>Added information about *Coverage History* and *Crap Score* in *How to interpret the results* page<li>Updated *Installing Code Coverage* section<li>Matches package version *0.3.0-preview*|
|
||||
|Feb 18, 2020|<li>Added *Generate combined report from EditMode and PlayMode tests* section<li>Matches package version *0.2.3-preview*|
|
||||
|Dec 11, 2019|<li>Matches package version *0.2.2-preview*|
|
||||
|Dec 3, 2019|<li>Added *pathFilters* section<li>Added examples for *assemblyFilters* and *pathFilters*<li>Added a reference to the *Coverage Recording ScriptingAPI*<li>Matches package version *0.2.1-preview*|
|
||||
|Nov 10, 2019|<li>Split documentation into separate pages<li>Matches package version *0.2.0-preview*|
|
||||
|Nov 5, 2019|<li>Updated UX design|
|
||||
|Sep 27, 2019|<li>Added *Using Code Coverage with Burst compiler* section<li>Added *Using Code Coverage with Code Optimization* section<li>Matches package version *0.1.0-preview.3*|
|
||||
|Sep 23, 2019|<li>Added *Coverage Recording* section<li>Matches package version *0.1.0-preview.2*|
|
||||
|Aug 16, 2019|<li>Added *How to interpret the results* section<li>Added *How it works* section|
|
||||
|Aug 7, 2019|<li>Added *Clear Coverage Data* setting to *Settings* table<li>Added *Note* in *Using Code Coverage* section about combined coverage of EditMode and PlayMode tests|
|
||||
|Aug 5, 2019|<li>Updated *About Code Coverage* section and *Settings* table|
|
||||
|May 15, 2019|<li>Document created. Matches package version *0.1.0-preview.0*|
|
@@ -0,0 +1,64 @@
|
||||
# How to interpret the results
|
||||
|
||||
This section assumes that you checked **HTML Report** in the [Code Coverage window](CodeCoverageWindow.md) or passed the `generateHtmlReport` option in `-coverageOptions` on the [command line](CoverageBatchmode.md). If you're running the tests in the Editor, a file viewer window opens up containing the coverage report once the test run has been finished. If you're running the tests from the command line, navigate to the `-coverageResultsPath` location with your file viewer. Open the `Report` folder then open `index.htm` in a web browser. This shows a summary of the coverage results from the tests.<br/>
|
||||
|
||||

|
||||
|
||||
## Summary view
|
||||
|
||||
The summary view is divided into several sections: Summary, Coverage History, Risk Hotspots and Coverage.
|
||||
|
||||
### Summary
|
||||
|
||||
This section shows a brief summary of the coverage results including the number of assemblies, classes, files and lines that were processed. The most important value is the **Line Coverage** which shows the current coverage percentage of all coverable lines. Coverable lines only include the lines that can be executed and are colored either green or red in the [File(s)](#files) section depending on whether the line was covered or not. Uncoverable lines are the lines that cannot be executed and are not colored in the [File(s)](#files) section; these include lines containing:
|
||||
- Assemblies, Classes, Constructors, Methods and Structs that are marked to be [excluded from coverage](UsingCodeCoverage.md#excluding-code-from-code-coverage)
|
||||
- Directives
|
||||
- Attributes
|
||||
- Method signatures
|
||||
- Class definitions
|
||||
- Unassigned variable declarations
|
||||
- Constant variable declarations
|
||||
- else/case/default keywords
|
||||
- Lines from other classes, when multiple classes are included in the same file
|
||||
- Blank lines
|
||||
|
||||
### Coverage History
|
||||
|
||||
This section only appears if you checked **Report History** in the [Code Coverage window](CodeCoverageWindow.md) or passed the `generateHtmlReportHistory` option in `-coverageOptions` on the [command line](CoverageBatchmode.md). The Coverage History displays a graph showing the total percentage coverage for every test run for this project. Aim to keep this percentage as high as possible. If it is decreasing, consider writing more tests to improve your coverage.
|
||||
|
||||
### Risk Hotspots
|
||||
|
||||
This section only appears if you checked **Additional Metrics** in the [Code Coverage window](CodeCoverageWindow.md) or passed the `generateAdditionalMetrics` option in `-coverageOptions` on the [command line](CoverageBatchmode.md).
|
||||
|
||||
The Risk Hotspots display information about any methods that have a Cyclomatic Complexity score that is greater than 15. The Cyclomatic Complexity score is a value that is based on the number of paths that can be taken through a method. The score will tend to be higher if a method has a large number of `if` or `switch` statements. For more detailed information see the [Wikipedia entry on Cyclomatic Complexity](https://en.wikipedia.org/wiki/Cyclomatic_complexity). You will also see information about any methods with a high Crap Score. CRAP stands for Change Risk Anti-Patterns. For more detailed information see this [article](https://testing.googleblog.com/2011/02/this-code-is-crap.html).
|
||||
|
||||
If there are any methods with a very high Cyclomatic Complexity or Crap Score, consider refactoring the method to reduce its complexity.
|
||||
|
||||
**Note:** NPath Complexity calculation and Branch Coverage are not implemented at present so will always appear as zero.
|
||||
|
||||
### Coverage
|
||||
By default, this shows a list of the assemblies that have been covered together with some stats showing how well covered they are. Select **Expand (+)** next to the assembly name to see a list of the classes or structs within the assembly and their associated coverage data. To see more detailed information for a particular class, select its name in the list.
|
||||
|
||||
## Class/Struct view
|
||||
|
||||
### Summary
|
||||
|
||||
Similar to the Summary section of the previous page, this section shows some brief statistics for the selected class. The most important value is the Line Coverage percentage. Select **Back (<)** in the top left hand corner to return to the previous screen.
|
||||
|
||||
### Coverage History
|
||||
|
||||
This section only appears if you checked **Report History** in the [Code Coverage window](CodeCoverageWindow.md) or passed the `generateHtmlReportHistory` option in `-coverageOptions` on the [command line](CoverageBatchmode.md). It shows a graph of the coverage percentage of the class/struct over time. Try to keep this value as high as you can. Make sure that as you add new code the coverage percentage is maintained by adding more tests.
|
||||
|
||||
### Metrics
|
||||
|
||||
The metrics section displays a list of the methods and properties of the class, along with each method's Cyclomatic Complexity, Crap Score and Sequence Coverage scores. Currently, the NPath Complexity and Branch Coverage aren't calculated, so will always appear as zero.
|
||||
|
||||
### File(s)
|
||||
|
||||
The File(s) section shows the C# source code for the selected class. Each line is colored either green or red depending on whether the line was covered or not. The number in the left column indicates the number of times that the line was executed during a Test Runner or Coverage Recording session.
|
||||
|
||||
### Coverage by test methods
|
||||
|
||||
This section only appears if you checked **Test Runner References** in the [Code Coverage window](CodeCoverageWindow.md) or passed the `generateTestReferences` option in `-coverageOptions` on the [command line](CoverageBatchmode.md).
|
||||
|
||||
It shows a list of test methods allowing you to see how each test contributes to the overall coverage. Select a test method to view the relevant code or hover over the code to see which test method executed it.
|
@@ -0,0 +1,43 @@
|
||||
# Installing Code Coverage
|
||||
|
||||
Before you install the package, make sure you have no errors in the [Console](https://docs.unity3d.com/Manual/Console.html) window (in red text).
|
||||
|
||||
## From the Unity Package Manager
|
||||
|
||||
Use the [Unity Package Manager](https://docs.unity3d.com/Packages/com.unity.package-manager-ui@latest) 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`.
|
||||
|
||||

|
||||
|
||||
To verify that Code Coverage has been installed correctly, open the Code Coverage window (go to **Window** > **Analysis** > **Code Coverage**). If you don't see the **Code Coverage** menu item, then Code Coverage did not install correctly.
|
||||
|
||||
## Manually from the Package Manifest
|
||||
|
||||
You can also install the Code Coverage package manually. To do this, add a reference to Code Coverage in your project's `Packages/manifest.json` file. There are two ways you can reference a specific version of the Code Coverage package, depending on how you use it.
|
||||
|
||||
### Using a production version of the package
|
||||
|
||||
You can point the Package Manager at a publicly available version. To do this manually, add it to `manifest.json`:
|
||||
|
||||
```json
|
||||
"dependencies": {
|
||||
//...
|
||||
"com.unity.testtools.codecoverage":"<full version number>"
|
||||
}
|
||||
```
|
||||
|
||||
### Using a local clone of the package
|
||||
|
||||
If you want to use a cloned version of the package, you can point the Package Manager at a local folder as the package location:
|
||||
|
||||
```json
|
||||
"dependencies": {
|
||||
//...
|
||||
"com.unity.testtools.codecoverage":"file:path/to/package/root"
|
||||
}
|
||||
```
|
||||
|
||||
To verify that Code Coverage has been installed correctly, open the Code Coverage window (go to **Window** > **Analysis** > **Code Coverage**). If you don't see the **Code Coverage** menu item, then Code Coverage did not install correctly.
|
@@ -0,0 +1,201 @@
|
||||
# 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 complete.
|
||||
|
||||

|
||||
|
||||
## Tasks
|
||||
|
||||
1. [What is Code Coverage](#1-what-is-code-coverage-sub2-minsub) (2 min)
|
||||
2. [Install the Code Coverage package](#2-install-the-code-coverage-package-sub2-minsub) (2 min)
|
||||
3. [Install the Asteroids sample project](#3-install-the-asteroids-sample-project-sub1-minsub) (1 min)
|
||||
4. [Enable Code Coverage](#4-enable-code-coverage-sub1-minsub) (1 min)
|
||||
5. [Understanding the game code: Shoot() function](#5-understanding-the-game-code-shoot-function-sub4-minsub) (4 min)
|
||||
6. [Generate a Coverage report from PlayMode tests](#6-generate-a-coverage-report-from-playmode-tests-sub3-minsub) (3 min)
|
||||
7. [Add Weapon tests to improve coverage](#7-add-weapon-tests-to-improve-coverage-sub3-minsub) (3 min)
|
||||
8. [Add a test for the LaserController](#8-add-a-test-for-the-lasercontroller-sub4-minsub) (4 min)
|
||||
9. [Clear the coverage data](#9-clear-the-coverage-data-sub1-minsub) (1 min)
|
||||
10. [Generate a Coverage report using Coverage Recording](#10-generate-a-coverage-report-using-coverage-recording-sub4-minsub) (4 min)
|
||||
|
||||
**Note:** Estimated times are shown for each task to give you a better understanding of the time required. These times are rough guidelines - it is fine to take as much or as little time as needed.
|
||||
|
||||
## 1. What is Code Coverage <sub>(2 min)</sub>
|
||||
|
||||
[Code Coverage](https://en.wikipedia.org/wiki/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](HowToInterpretResults.md) 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](CoverageRecording.md) 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 <sub>(2 min)</sub>
|
||||
**Note:** Skip this task if the package is already installed.
|
||||
|
||||
Use the [Unity Package Manager](https://docs.unity3d.com/Packages/com.unity.package-manager-ui@latest) 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`.
|
||||
|
||||

|
||||
|
||||
To verify that Code Coverage has been installed correctly, open the Code Coverage window (go to **Window** > **Analysis** > **Code Coverage**). If you don't see the **Code Coverage** menu item, then Code Coverage did not install correctly.
|
||||
|
||||
## 3. Install the Asteroids sample project <sub>(1 min)</sub>
|
||||
|
||||
1. In the [Unity Package Manager](https://docs.unity3d.com/Packages/com.unity.package-manager-ui@latest) (**Window** > **Package Manager**) select the **Code Coverage** package, if not already selected.
|
||||
2. Find the **Samples** section in the package details (right hand side) and select **Import** next to **Code Coverage Tutorial**.<br/><br/>
|
||||

|
||||
|
||||
## 4. Enable Code Coverage <sub>(1 min)</sub>
|
||||
|
||||
To enable Code Coverage open the [Code Coverage window](CodeCoverageWindow.md) (go to **Window** > **Analysis** > **Code Coverage**) and select **Enable Code Coverage** if not already selected, to be able to generate Coverage data and reports.
|
||||
|
||||

|
||||
|
||||
**Note:** Enabling Code Coverage adds some overhead to the editor and can affect the performance.
|
||||
|
||||
## 5. Understanding the game code: Shoot() function <sub>(4 min)</sub>
|
||||
|
||||
1. Go to `Asteroids/Scenes` in Project View and open the **Asteroids** scene.<br/>
|
||||
This is located in `Assets/Samples/Code Coverage/<version>/Code Coverage Tutorial`.
|
||||
|
||||
2. Hit **Play** and play the game for a minute or two.<br/>
|
||||

|
||||
Use the arrow keys to move and the spacebar to shoot.
|
||||
|
||||
3. Exit PlayMode.
|
||||
|
||||
4. Open the `Scripts/Controllers/SpaceshipController.cs` script.
|
||||
|
||||
5. Study the **Shoot** function.
|
||||
```
|
||||
If Weapon is Basic, the Prefabs/Weapons/Projectile prefab is instantiated
|
||||
If Weapon is Laser, the Prefabs/Weapons/Laser prefab is instantiated
|
||||
```
|
||||
|
||||
## 6. Generate a Coverage report from PlayMode tests <sub>(3 min)</sub>
|
||||
|
||||
1. Open the [Code Coverage window](CodeCoverageWindow.md) (go to **Window** > **Analysis** > **Code Coverage**).<br/><br/>
|
||||

|
||||
|
||||
2. If you see this warning select **Switch to debug mode**.<br/>
|
||||

|
||||
[Code Optimization](https://docs.unity3d.com/2020.1/Documentation/Manual/ManagedCodeDebugging.html#CodeOptimizationMode) was introduced in Unity 2020.1; in _Release mode_ the code is optimized and therefore not directly represented by the original code. Therefore, _Debug mode_ is required in order to obtain accurate code coverage information.
|
||||
|
||||
3. Click the **Included Assemblies** dropdown to make sure only<br/>
|
||||
`Unity.TestTools.CodeCoverage.Sample.Asteroids` and<br/>
|
||||
`Unity.TestTools.CodeCoverage.Sample.Asteroids.Tests` are selected.<br/><br/>
|
||||

|
||||
|
||||
4. Make sure **HTML Report**, **Report History**, **Auto Generate Report** and **Auto Open Report** are all checked.
|
||||

|
||||
|
||||
5. Switch to the [Test Runner](https://docs.unity3d.com/Packages/com.unity.test-framework@latest/index.html?subfolder=/manual/workflow-run-test.html) window, select the **PlayMode** tab and hit **Run All** tests.<br/><br/>
|
||||

|
||||
|
||||
6. When the tests finish running, a file viewer window will open up containing the coverage report. Select `index.htm`.
|
||||
|
||||
7. Look for the classes with low coverage, especially **LaserController**, **BaseProjectile** and **ProjectileController**.
|
||||
|
||||
You can sort the results by _Line coverage_.
|
||||
|
||||

|
||||
|
||||
See also [How to interpret the results](HowToInterpretResults.md).
|
||||
|
||||
## 7. Add Weapon tests to improve coverage <sub>(3 min)</sub>
|
||||
|
||||
1. Open the `Tests/WeaponTests.cs` script.
|
||||
|
||||
2. Uncomment all the tests (from _line 35_ down to _line 237_).
|
||||
|
||||
3. Back in the **Test Runner**, hit **Run All** tests again.
|
||||
|
||||
4. When the tests finish running, a file viewer window will open up containing the coverage report. Select `index.htm`.
|
||||
|
||||
5. Notice that now **BaseProjectile** and **ProjectileController** coverage is considerably higher, but **LaserController** has not improved much.
|
||||
|
||||

|
||||
|
||||
## 8. Add a test for the LaserController <sub>(4 min)</sub>
|
||||
|
||||
1. Open the `Tests/WeaponTests.cs` script.
|
||||
|
||||
2. Go to the **\_18\_LaserFiresSuccessfully** test in line 225.
|
||||
|
||||
3. Uncomment and study the code.
|
||||
|
||||
4. Back in the **Test Runner**, hit **Run All** tests again.
|
||||
|
||||
5. When the tests finish running, a file viewer window will open up containing the coverage report. Select `index.htm`.
|
||||
|
||||
6. Notice how the coverage for **LaserController** has improved.<br/>
|
||||

|
||||
|
||||
7. Select the **LaserController** class to enter the class view and notice that about 2/3 (65%) of the code is now covered (green).
|
||||
|
||||

|
||||
|
||||
Complete the [Bonus Task](#11-bonus-task-sub5-8-minsub) at the end of the tutorial to get 100% coverage!
|
||||
|
||||
## 9. Clear the coverage data <sub>(1 min)</sub>
|
||||
|
||||
1. Open the [Code Coverage window](CodeCoverageWindow.md) (go to **Window** > **Analysis** > **Code Coverage**).
|
||||
|
||||
2. Select **Clear Results** and confirm.
|
||||
|
||||
3. Select **Clear History** and confirm.
|
||||
|
||||
## 10. Generate a Coverage report using Coverage Recording <sub>(4 min)</sub>
|
||||
|
||||
1. Go to `Asteroids/Scenes` in Project View and open the **Asteroids** scene, if not opened already.
|
||||
|
||||
2. Open the [Code Coverage window](CodeCoverageWindow.md). Make sure **HTML Report**, **Report History**, **Auto Generate Report** and **Auto Open Report** all are checked.<br/>
|
||||

|
||||
|
||||
3. Select **Start Recording**.<br/>
|
||||

|
||||
|
||||
4. Hit **Play** to play the game and **exit** PlayMode before you get **8000** points.
|
||||

|
||||
|
||||
5. Select **Stop Recording**.<br/>
|
||||

|
||||
|
||||
6. A file viewer window will open up containing the coverage report. Select `index.htm`.
|
||||
|
||||
7. Notice that **LaserController** has 0% coverage.<br/>
|
||||

|
||||
|
||||
8. Go back to the **Code Coverage window**.
|
||||
|
||||
9. Select **Start Recording**.
|
||||
|
||||
10. Now hit **Play** to play the game again but this time **exit** PlayMode when you get **8000** points.
|
||||
|
||||
11. Select **Stop Recording**.
|
||||
|
||||
12. Notice that **LaserController** coverage is now 100%.<br/>
|
||||

|
||||
|
||||
See also [How to interpret the results](HowToInterpretResults.md).
|
||||
<br/><br/>
|
||||
|
||||
## 11. Bonus task <sub>(5-8 min)</sub>
|
||||
|
||||
Write a new test that checks that the laser gets destroyed after 2 seconds, which will also cover the rest of the code in **LaserController**.
|
||||
|
||||
**Suggested name:** _19_LaserFiresAndIsDestroyedAfterTwoSeconds.
|
||||
**Hint:** You can use `yield return new WaitForSeconds(2f);` to wait for 2 seconds.
|
||||
|
||||
<br/>
|
||||
|
||||
---
|
||||
|
||||
<br/>
|
||||
|
||||
### Well done for finishing the Code Coverage tutorial!
|
||||
|
||||
For questions and feedback please visit the [Testing & Automation](https://forum.unity.com/forums/testing-automation.211/) forum section to browse current conversations or start a new thread. Please use the **code coverage** tag.
|
@@ -0,0 +1,41 @@
|
||||
* [About Code Coverage](index)
|
||||
* [What's new](whats-new.md)
|
||||
* [Upgrade guide](upgrade-guide.md)
|
||||
* [Code Coverage package](index#code-coverage-package)
|
||||
* [Coverage HTML Report](index#coverage-html-report)
|
||||
* [Other Reports](index#other-reports)
|
||||
* [Coverage Summary Badges](index#coverage-summary-badges)
|
||||
* [Quickstart](Quickstart)
|
||||
* [What is Code Coverage](Quickstart#1-what-is-code-coverage-sub2-minsub)
|
||||
* [Install the Code Coverage package](Quickstart#2-install-the-code-coverage-package-sub2-minsub)
|
||||
* [Install the Asteroids sample project](Quickstart#3-install-the-asteroids-sample-project-sub1-minsub)
|
||||
* [Enable Code Coverage](Quickstart#4-enable-code-coverage-sub1-minsub)
|
||||
* [Understanding the game code: Shoot() function](Quickstart.html#5-understanding-the-game-code-shoot-function-sub4-minsub)
|
||||
* [Generate a Coverage report from PlayMode tests](Quickstart#6-generate-a-coverage-report-from-playmode-tests-sub3-minsub)
|
||||
* [Add Weapon tests to improve coverage](Quickstart#7-add-weapon-tests-to-improve-coverage-sub3-minsub)
|
||||
* [Add a test for the LaserController](Quickstart#8-add-a-test-for-the-lasercontroller-sub4-minsub)
|
||||
* [Clear the coverage data](Quickstart#9-clear-the-coverage-data-sub1-minsub)
|
||||
* [Generate a Coverage report using Coverage Recording](Quickstart#10-generate-a-coverage-report-using-coverage-recording-sub4-minsub)
|
||||
* [Installing Code Coverage](InstallingCodeCoverage)
|
||||
* [From the Unity Package Manager](InstallingCodeCoverage#from-the-unity-package-manager)
|
||||
* [Manually from the Package Manifest](InstallingCodeCoverage#manually-from-the-package-manifest)
|
||||
* [Using Code Coverage](UsingCodeCoverage)
|
||||
* [Code Coverage window](CodeCoverageWindow)
|
||||
* [Using Code Coverage with Test Runner](CoverageTestRunner)
|
||||
* [On demand coverage recording](CoverageRecording)
|
||||
* [Using Code Coverage in batchmode](CoverageBatchmode)
|
||||
* [Using Code Coverage with Burst compiler](UsingCodeCoverage#using-code-coverage-with-burst-compiler)
|
||||
* [Using Code Coverage with Code Optimization](UsingCodeCoverage#using-code-coverage-with-code-optimization)
|
||||
* [Excluding code from Code Coverage](UsingCodeCoverage#excluding-code-from-code-coverage)
|
||||
* [Ignoring tests for Code Coverage](UsingCodeCoverage#ignoring-tests-for-code-coverage)
|
||||
* [Subscribing to Code Coverage session events](UsingCodeCoverage#subscribing-to-code-coverage-session-events)
|
||||
* [How to interpret the results](HowToInterpretResults)
|
||||
* [Summary View](HowToInterpretResults#summary-view)
|
||||
* [Class/Struct View](HowToInterpretResults#classstruct-view)
|
||||
* [Technical details](TechnicalDetails)
|
||||
* [How it works](TechnicalDetails#how-it-works)
|
||||
* [Requirements](TechnicalDetails#requirements)
|
||||
* [3rd party libraries used](TechnicalDetails#3rd-party-libraries-used)
|
||||
* [Known limitations](TechnicalDetails#known-limitations)
|
||||
* [Document revision history](DocumentRevisionHistory)
|
||||
* [Archive](DocumentArchive)
|
@@ -0,0 +1,23 @@
|
||||
# Technical details
|
||||
|
||||
## How it works
|
||||
|
||||
The package is a client of the coverage API. For more information, see the [coverage API's documentation](https://docs.unity3d.com/ScriptReference/TestTools.Coverage.html). The package uses a combination of this API and C# reflection to output the test coverage data in the OpenCover format. Optionally, a third-party report generator will then parse the OpenCover data and generate a report (HTML, SonarQube, Cobertura, LCOV).
|
||||
|
||||
## Requirements
|
||||
|
||||
This version of the Code Coverage package is compatible with the following versions of the Unity Editor:
|
||||
|
||||
* 2019.3 and later
|
||||
|
||||
## Third-party libraries used
|
||||
|
||||
* [ReportGenerator](https://github.com/danielpalme/ReportGenerator) - v5.0.4
|
||||
|
||||
## Known limitations
|
||||
|
||||
Code Coverage includes the following known limitations:
|
||||
|
||||
* Code Coverage currently only supports the [OpenCover](https://github.com/OpenCover/opencover) format.
|
||||
* Code Coverage currently only supports code run in the Editor and not in Standalone/Player.
|
||||
* NPath Complexity calculation and Branch Coverage are not implemented at present so they will always appear as zero in the coverage report.
|
@@ -0,0 +1,40 @@
|
||||
# Using Code Coverage
|
||||
|
||||
## Using Code Coverage with Burst compiler
|
||||
|
||||
If you use the [Burst package](https://docs.unity3d.com/Packages/com.unity.burst@latest) and have jobs compiled with Burst, you will need to disable Burst compilation in order to get full coverage. To disable Burst compilation you can do **one** of the following:
|
||||
|
||||
- Uncheck **Enable Compilation** under **Jobs** > **Burst** > **Enable Compilation**.
|
||||
- Pass `--burst-disable-compilation` to the command line.
|
||||
|
||||
## Using Code Coverage with Code Optimization
|
||||
|
||||
Code Optimization was introduced in 2020.1. Code Optimization mode defines whether Unity Editor compiles scripts in Debug or Release mode. Debug mode enables C# debugging and it is required in order to obtain accurate code coverage. To ensure Code optimization is set to Debug mode you can do **one** of the following:
|
||||
|
||||
- Switch to Debug mode in the Editor (bottom right corner, select the **Bug icon** > **Switch to debug mode**).
|
||||
- Using the CompilationPipeline api, set `CompilationPipeline.codeOptimization = CodeOptimization.Debug`.
|
||||
- Pass `-debugCodeOptimization` to the command line.
|
||||
|
||||
## Excluding code from Code Coverage
|
||||
|
||||
Any code that should not be contributing to the Code Coverage calculation can be excluded by adding the [`ExcludeFromCoverage`](https://docs.unity3d.com/ScriptReference/TestTools.ExcludeFromCoverageAttribute.html) attribute. This attribute can be added to Assemblies, Classes, Constructors, Methods and Structs. Note that you can also use the .NET [`ExcludeFromCodeCoverage`](https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.codeanalysis.excludefromcodecoverageattribute?view=netcore-2.0) attribute.
|
||||
|
||||
## Ignoring tests for Code Coverage
|
||||
|
||||
To ignore tests when running with Code Coverage, use the [ConditionalIgnore](https://docs.unity3d.com/Packages/com.unity.test-framework@latest/index.html?subfolder=/manual/reference-attribute-conditionalignore.html) attribute, passing the `"IgnoreForCoverage"` ID.
|
||||
|
||||
#### Example
|
||||
```
|
||||
public class MyTestClass
|
||||
{
|
||||
[Test, ConditionalIgnore("IgnoreForCoverage", "This test is disabled when ran with code coverage")]
|
||||
public void TestNeverRunningWithCodeCoverage()
|
||||
{
|
||||
Assert.Pass();
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Subscribing to Code Coverage session events
|
||||
|
||||
Use the [Events API](https://docs.unity3d.com/Packages/com.unity.testtools.codecoverage@latest/index.html?subfolder=/api/UnityEditor.TestTools.CodeCoverage.Events.html) to subscribe to events invoked during a Code Coverage session.
|
@@ -0,0 +1,34 @@
|
||||
apiRules:
|
||||
- exclude:
|
||||
# inherited Object methods
|
||||
uidRegex: ^System\.Object\..*$
|
||||
type: Method
|
||||
- exclude:
|
||||
# mentioning types from System.* namespace
|
||||
uidRegex: ^System\..*$
|
||||
type: Type
|
||||
- exclude:
|
||||
hasAttribute:
|
||||
uid: System.ObsoleteAttribute
|
||||
type: Member
|
||||
- exclude:
|
||||
hasAttribute:
|
||||
uid: System.ObsoleteAttribute
|
||||
type: Type
|
||||
- exclude:
|
||||
hasAttribute:
|
||||
uid: System.ComponentModel.EditorBrowsableAttribute
|
||||
ctorArguments:
|
||||
- System.ComponentModel.EditorBrowsableState.Never
|
||||
- exclude:
|
||||
uidRegex: ^OpenCover\.Framework\.Model
|
||||
type: namespace
|
||||
- exclude:
|
||||
uidRegex: ^Mono\.Reflection
|
||||
type: namespace
|
||||
- exclude:
|
||||
uidRegex: Unity.TestTools.CodeCoverage.Editor.Test*
|
||||
type: namespace
|
||||
- exclude:
|
||||
uidRegex: UnityEditor.TestTools.CodeCoverage.Tests
|
||||
type: namespace
|
After Width: | Height: | Size: 131 KiB |
After Width: | Height: | Size: 6.4 KiB |
After Width: | Height: | Size: 6.6 KiB |
After Width: | Height: | Size: 114 KiB |
After Width: | Height: | Size: 55 KiB |
After Width: | Height: | Size: 102 KiB |
After Width: | Height: | Size: 122 KiB |
After Width: | Height: | Size: 51 KiB |
After Width: | Height: | Size: 198 KiB |
After Width: | Height: | Size: 33 KiB |
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 103 KiB |
After Width: | Height: | Size: 130 KiB |
After Width: | Height: | Size: 145 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 55 KiB |
After Width: | Height: | Size: 8.6 KiB |
After Width: | Height: | Size: 9.5 KiB |
After Width: | Height: | Size: 74 KiB |
After Width: | Height: | Size: 74 KiB |
After Width: | Height: | Size: 67 KiB |
After Width: | Height: | Size: 155 KiB |
After Width: | Height: | Size: 2.9 KiB |
After Width: | Height: | Size: 130 KiB |
After Width: | Height: | Size: 6.5 KiB |
After Width: | Height: | Size: 946 B |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 4.9 KiB |
After Width: | Height: | Size: 197 KiB |
After Width: | Height: | Size: 117 KiB |
After Width: | Height: | Size: 139 KiB |
@@ -0,0 +1,39 @@
|
||||
# About Code Coverage
|
||||
|
||||
[Code Coverage](https://en.wikipedia.org/wiki/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](HowToInterpretResults.md) 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.
|
||||
|
||||
## Code Coverage package
|
||||
|
||||
Use the Code Coverage package with the [Test Runner](CoverageTestRunner.md) to gather and present test coverage information. When you run your tests with code coverage enabled you can see exactly which lines of your code are executed when the tests run in addition to whether the tests passed or failed. See [Using Code Coverage with Test Runner](CoverageTestRunner.md).
|
||||
|
||||
Once a test run has completed, the Code Coverage package will generate an [HTML coverage report](HowToInterpretResults.md) showing which lines of your code are covered by tests. Code Coverage currently supports **PlayMode** and **EditMode** tests. It also allows you to track the code coverage changes through time.
|
||||
|
||||
Additionally, the Code Coverage package offers a [Coverage Recording](CoverageRecording.md) feature which allows capturing coverage data on demand, in case you do not have tests in your project or doing manual testing.
|
||||
|
||||
The [Quickstart](Quickstart.md) guide will give you an insight into the package.
|
||||
|
||||
## Coverage HTML report
|
||||
|
||||
Shown below is an example of the top level page of an HTML report generated by the package.
|
||||
|
||||

|
||||
|
||||
### Class view
|
||||
|
||||
This view shows some brief statistics for the selected class as well as the C# source code. Each line will be colored either green or red depending on whether the line was covered or not.
|
||||
|
||||

|
||||
|
||||
For more information see [How to interpret the results](HowToInterpretResults.md).
|
||||
|
||||
## Other reports
|
||||
|
||||
The package can produce [SonarQube](https://docs.sonarqube.org/latest/analysis/generic-test), [Cobertura](https://cobertura.github.io/cobertura) and [LCOV](https://github.com/linux-test-project/lcov) reports.
|
||||
|
||||
## Coverage summary badges
|
||||
|
||||
Additionally, the package can produce simple badges in SVG and PNG format, showing the current percentage of code that is covered.
|
||||
|
||||

|