我需要做什么才能让 TeamCity 针对我的项目正确生成覆盖率报告?
我有一个针对我的代码运行 DotCover 的自定义 powershell 构建脚本。构建脚本有一个像这样的覆盖方法
Function Invoke-NUnitWithCoverage ( [string] $targetAssembly, [string] $outputDir, [string] $runCommand){
$fileName = Get-TestFileName $outputDir $runCommand
$xmlFile = "$fileName-TestResults.xml"
$txtFile = "$fileName-TestResults.txt"
$coverageFile = "$fileName-CoverageResults.xml"
exec{ dotcover.exe analyse /TargetExecutable=$nunitRunnerDir\nunit-console.exe /TargetArguments="$targetAssembly /fixture:$runCommand /xml=$xmlFile /out=$txtFile /nologo /framework=4.0" /Output=$coverageFile /ReportType=xml } "Running code coverage '$runCommand' failed."
Write-Host "##teamcity[importData type='dotNetCoverage' tool='dotcover' path='$coverageFile']"
}
TeamCity 上的输出显示正确,但它没有生成报告。这是 TeamCity 日志。如您所见,存在生成失败。
TL;博士;
如果您不想阅读整个日志,这里是关键行。
[JetBrains dotCover] Failed to merge snapshots. Unknown storage type. Unknown storage type
...
[JetBrains dotCover] Unhandled exception: The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
...
[JetBrains dotCover] Report generation failed. Too short file
...
[JetBrains dotCover] Failed to create zipped snapshot. Too short file
...
[JetBrains dotCover] 'E:\BuildAgent\temp\buildTmp\dotCover5237101456909205485Merge' is not a coverage snapshot.
##teamcity[importData type='dotNetCoverage' tool='dotcover' path='E:\BuildAgent\work\81eb7c2fdfcfc0af\build-artifacts\results\TransCanada-GCTS-App-Tests-CoverageResults.xml']
....
....
Waiting for 16 service processes to complete
[10:32:34]Processing 1 coverage report(s)
[10:32:34]Generating coverage report by dotcover for files: [E:\BuildAgent\work\81eb7c2fdfcfc0af\build-artifacts\results\TransCanada-GCTS-App-Tests-CoverageResults.xml, E:\BuildAgent\work\81eb7c2fdfcfc0af\build-artifacts\results\TransCanada-GCTS-Framework-Test-CoverageResults.xml, E:\BuildAgent\work\81eb7c2fdfcfc0af\build-artifacts\results\TransCanada-GCTS-CommonDataService-Tests-Unit-CoverageResults.xml, E:\BuildAgent\work\81eb7c2fdfcfc0af\build-artifacts\results\TransCanada-GCTS-Contracts-Tests-Unit-CoverageResults.xml, E:\BuildAgent\work\81eb7c2fdfcfc0af\build-artifacts\results\TransCanada-GCTS-Invoicing-Tests-Unit-CoverageResults.xml, E:\BuildAgent\work\81eb7c2fdfcfc0af\build-artifacts\results\TransCanada-GCTS-FlowingGasService-Tests-Unit-CoverageResults.xml, E:\BuildAgent\work\81eb7c2fdfcfc0af\build-artifacts\results\TransCanada-GCTS-JobSchedulingService-Tests-Unit-CoverageResults.xml, E:\BuildAgent\work\81eb7c2fdfcfc0af\build-artifacts\results\TransCanada-GCTS-CommonDataService-Tests-Integration-CoverageResults.xml, E:\BuildAgent\work\81eb7c2fdfcfc0af\build-artifacts\results\TransCanada-GCTS-Contracts-Tests-Integration-CoverageResults.xml, E:\BuildAgent\work\81eb7c2fdfcfc0af\build-artifacts\results\TransCanada-GCTS-Invoicing-Tests-Integration-CoverageResults.xml, E:\BuildAgent\work\81eb7c2fdfcfc0af\build-artifacts\results\TransCanada-GCTS-FlowingGasService-Tests-Integration-CoverageResults.xml, E:\BuildAgent\work\81eb7c2fdfcfc0af\build-artifacts\results\TransCanada-GCTS-JobSchedulingService-Tests-Integration-CoverageResults.xml, E:\BuildAgent\work\81eb7c2fdfcfc0af\build-artifacts\results\TransCanada-GCTS-CommonDataService-Tests-Acceptance-CoverageResults.xml, E:\BuildAgent\work\81eb7c2fdfcfc0af\build-artifacts\results\TransCanada-GCTS-Contracts-Tests-Acceptance-CoverageResults.xml, E:\BuildAgent\work\81eb7c2fdfcfc0af\build-artifacts\results\TransCanada-GCTS-FlowingGasService-Tests-Acceptance-CoverageResults.xml, E:\BuildAgent\work\81eb7c2fdfcfc0af\build-artifacts\results\TransCanada-GCTS-Invoicing-Tests-Acceptance-CoverageResults.xml]
[10:32:34]Get dotCover version (1s)
[10:32:35]Started dotCover: E:\BuildAgent\tools\dotCover\dotCover.exe version E:\BuildAgent\temp\buildTmp\dotCover2609519531914093171Version
[10:32:35]
Output: JetBrains dotCover Console Runner v2.7.2.84. Copyright (c) 2009-2014 JetBrains s.r.o. All rights reserved.
[10:32:35]dotCover exited with code: 0
[10:32:35]Use DotCover 2.7.x commands set
[10:32:35]Merge dotCover reports (10s)
[10:32:45]Started dotCover: E:\BuildAgent\tools\dotCover\dotCover.exe merge E:\BuildAgent\temp\buildTmp\dotcover6392358845042650216.xml
[10:32:45]
Output: JetBrains dotCover Console Runner v2.7.2.84. Copyright (c) 2009-2014 JetBrains s.r.o. All rights reserved.
[JetBrains dotCover] Snapshot merging started [12/3/2014 10:32:44 AM]
[JetBrains dotCover] Source snapshots number: 16
Merging snapshots 1-5
[JetBrains dotCover] Failed to merge snapshots. Unknown storage type. Unknown storage type
[10:32:45]dotCover exited with code: -2
[10:32:45]dotCover returned non-zero exit code.
[10:32:45]Remove dotCover snapshot files
[10:32:45]Started dotCover: E:\BuildAgent\tools\dotCover\dotCover.exe delete E:\BuildAgent\temp\buildTmp\dotcover4610370083173723447.xml
[10:32:45]
Output: JetBrains dotCover Console Runner v2.7.2.84. Copyright (c) 2009-2014 JetBrains s.r.o. All rights reserved.
[JetBrains dotCover] Unhandled exception: The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
[10:32:45]dotCover exited with code: -10
[10:32:45]dotCover returned non-zero exit code.
[10:32:45]Generate dotCover report (7s)
[10:32:52]Started dotCover: E:\BuildAgent\tools\dotCover\dotCover.exe report E:\BuildAgent\temp\buildTmp\dotcover8678535704262330052.xml
[10:32:52]
Output: JetBrains dotCover Console Runner v2.7.2.84. Copyright (c) 2009-2014 JetBrains s.r.o. All rights reserved.
[JetBrains dotCover] Report generation started [12/3/2014 10:32:45 AM]
[JetBrains dotCover] Report generation failed. Too short file
[10:32:52]dotCover exited with code: -2
[10:32:52]dotCover returned non-zero exit code.
[10:32:52]Generate dotCover HTML report
[10:32:52]Packing snapshot files (6s)
[10:32:59]Started dotCover: E:\BuildAgent\tools\dotCover\dotCover.exe zip E:\BuildAgent\temp\buildTmp\dotcover1602620273009840026.xml
[10:32:59]
Output: JetBrains dotCover Console Runner v2.7.2.84. Copyright (c) 2009-2014 JetBrains s.r.o. All rights reserved.
[JetBrains dotCover] Failed to create zipped snapshot. Too short file
[10:32:59]dotCover exited with code: -2
[10:32:59]dotCover returned non-zero exit code.
[10:32:59]Remove dotCover snapshot files (6s)
[10:33:06]No statistics values are provided by dotCover report generator (recommended)