Как получить покрытие DotCover в TeamCity от Cake
Недавно я применил инструмент сборки Cake, но я изо всех сил пытаюсь получить отчеты о покрытии модульных тестов DotCover для отображения в TeamCity.
Я пробовал следующую задачу:
Task("Run-Regression-Tests")
.IsDependentOn("Build")
.Does(() =>
{
var resultPath = artifactsDirectory + File("results.dcvr");
DotCoverCover(tool =>
{
tool.NUnit3(new[] {
"./Foo.UnitTests/bin/" + configuration + "/Foo.UnitTests.dll",
"./Bar.UnitTests/bin/" + configuration + "/Bar.UnitTests.dll",
"./Baz.IntegrationTests/bin/" + configuration + "/Baz.IntegrationTests.dll"
}, new NUnit3Settings {
NoResults = true
});
},
resultPath,
new DotCoverCoverSettings()
.WithFilter("+:Foo.Domain"));
TeamCity.ImportDotCoverCoverage(resultPath);
});
Однако это приводит к следующему выводу из TeamCity:
// Output immediately after unit test success report:
[03:01:52][Step 1/1] [JetBrains dotCover] Coverage session finished [30/09/2017 03:01:52]
[03:01:52][Step 1/1] [JetBrains dotCover] Coverage results post-processing started [30/09/2017 03:01:52]
[03:01:53][Step 1/1] [JetBrains dotCover] Coverage results post-processing finished [30/09/2017 03:01:53]
[03:01:53][Step 1/1]
[03:01:53][Step 1/1] ========================================
[03:01:53][Step 1/1] Create Octopus Release
[03:01:53][Step 1/1] ========================================
[03:01:53][Step 1/1] Importing data from 'artifacts/results.dcvr' (7.49 MB) with 'dotNetCoverage' processor
// After cake finishes:
[03:02:11]Waiting for 1 service processes to complete
[03:02:11]Processing 1 coverage report(s)
[03:02:11]Generating coverage report by dotcover for files: [C:\TeamCity\buildAgent\work\47e2e68a6c48ce48\artifacts\results.dcvr]
[03:02:11]Get dotCover version (1s)
[03:02:13]Use DotCover 2016 and higher commands set
[03:02:13]Merge dotCover reports
[03:02:14][Merge dotCover reports] Started dotCover: C:\TeamCity\buildAgent\tools\dotCover\dotCover.exe merge C:\TeamCity\buildAgent\temp\buildTmp\dotcover4470082908956100659.xml
[03:02:14]
[Merge dotCover reports] Output: JetBrains dotCover Console Runner 2017.1.1. Build 108.0.20170407.130252
Copyright (c) 2009-2017 JetBrains s.r.o. All rights reserved.
[JetBrains dotCover] Snapshot merging started [30/09/2017 03:02:13]
[JetBrains dotCover] Source snapshots number: 1
[03:02:14][Merge dotCover reports] [JetBrains dotCover] Failed to merge snapshots. Set of standalone sections doesn't comply ReverseFunctionCoverageSnapshotDataDescriptor specification. Set of standalone sections doesn't comply ReverseFunctionCoverageSnapshotDataDescriptor specification
[03:02:14]
[Merge dotCover reports]
[03:02:14][Merge dotCover reports] dotCover exited with code: -2
[03:02:14][Merge dotCover reports] dotCover returned non-zero exit code.
[03:02:14]Remove dotCover snapshot files
[03:02:14]Generate dotCover report
[03:02:15][Generate dotCover report] Started dotCover: C:\TeamCity\buildAgent\tools\dotCover\dotCover.exe report C:\TeamCity\buildAgent\temp\buildTmp\dotcover1750892168641886115.xml
[03:02:15]
[Generate dotCover report] Output: JetBrains dotCover Console Runner 2017.1.1. Build 108.0.20170407.130252
Copyright (c) 2009-2017 JetBrains s.r.o. All rights reserved.
[03:02:15][Generate dotCover report] [JetBrains dotCover] Report source "C:\TeamCity\buildAgent\temp\buildTmp\dotCover1103887209553630063Merge" doesn't exist.
[03:02:15]
[Generate dotCover report]
[03:02:15][Generate dotCover report] dotCover exited with code: -2
[03:02:15][Generate dotCover report] dotCover returned non-zero exit code.
[03:02:15]Generate dotCover HTML report
[03:02:15]Packing snapshot files
[03:02:15][Packing snapshot files] Started dotCover: C:\TeamCity\buildAgent\tools\dotCover\dotCover.exe zip C:\TeamCity\buildAgent\temp\buildTmp\dotcover5049141835197969589.xml
[03:02:15]
[Packing snapshot files] Output: JetBrains dotCover Console Runner 2017.1.1. Build 108.0.20170407.130252
Copyright (c) 2009-2017 JetBrains s.r.o. All rights reserved.
[03:02:15][Packing snapshot files] [JetBrains dotCover] Source file doesn't exist.
Кажется, что TeamCity пытается объединить снимки точек покрытия, но я не думаю, что я говорю об этом. Я также нахожу странным, что артефакты /results.dcvr загружаются после запуска задачи развертывания для осьминога
Я пытался использовать DotCoverAnalyze с resultPath "result.xml", но TeamCity сообщает, что это неверный формат файла.
Итак, как вы собираете и импортируете покрытие DotCover с помощью торта и TeamCity?
1 ответ
Вот как я сейчас импортирую отчет о покрытии dotCover в TeamCity. Обратите внимание, как я указываю абсолютный путь к домашнему каталогу DotCover.exe, чтобы переопределить пакет DotCover.exe. Это может быть полезно, когда может быть несовместимость между встроенной версией DotCover и той, которую вы используете с Cake (например, найденной в вашем .\tools
папка.
Task("Run-Unit-Tests")
.IsDependentOn("Build")
.Does(() =>
{
DotCoverCover((ICakeContext c) => {
c.NUnit3("./src/**/bin/x64/" + parameters.Configuration + "/Foo.Test.dll",
new NUnit3Settings
{
Results = parameters.Paths.TestResult,
TeamCity = parameters.IsTeamCity
}
);
},
parameters.Paths.CoverageResult,
new DotCoverCoverSettings()
.WithFilter("+:Foo")
.WithFilter("-:Foo.Test"));
})
.Finally(() =>
{
if(parameters.IsTeamCity)
{
TeamCity.ImportData("nunit", parameters.Paths.TestResult);
TeamCity.ImportDotCoverCoverage(
parameters.Paths.CoverageResult,
MakeAbsolute(Directory("./tools/JetBrains.dotCover.CommandLineTools/tools")));
}
else
{
DotCoverReport(
parameters.Paths.CoverageResult,
parameters.Paths.CoverageResult.ChangeExtension("html"),
new DotCoverReportSettings
{
ReportType = DotCoverReportType.HTML
});
}
});