Hello! We run code coverage through the command line for our build automation. The line coverage generated when we run code coverage in batch mode is different than when run through the editor. We’ve observed this behaviour on all of our projects. It seems like when run through batchmode, code coverage includes assemblies that are not included in the project’s Settings.json file, even though the useProjectSettings option is enabled.
We are generating a single report for both edit mode and play mode tests. Here are the commands we use:
(We use the same command for playmode, but with the testPlatform set to PlayMode)
Unity.exe
-runTests
-batchmode
-buildTarget WebGL
-testPlatform EditMode
-projectPath .
-logFile "<path-here>"
-testResults "<path-here>"
-debugCodeOptimization
-enableCodeCoverage
-coverageResultsPath "<path-here>"
-coverageOptions "generateAdditionalMetrics;useProjectSettings;dontClear"
Unity.exe
-batchmode
-buildTarget WebGL
-logFile "<path-here>"
-projectPath .
-debugCodeOptimization
-enableCodeCoverage
-coverageResultsPath "<path-here"
-coverageOptions "generateHtmlReport;generateHtmlReportHistory;generateBadgeReport;generateAdditionalMetrics;useProjectSettings"
-quit
This is run through Jenkins.