I've recently adopted the build tool Cake, but I'm struggling to get DotCover unit test coverage reports to show in TeamCity.
I've tried the following task:
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);
});
However this produces the following output from 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.
It seems that TeamCity is trying to merge dotcover snapshots but I don't think I'm telling it to. I also find it strange that the artifacts/results.dcvr are being uploaded after the deploy to octopus task has started
I've tried using DotCoverAnalyze with a resultPath of "result.xml" but TeamCity reports that it is an invalid file format.
So, how do you collect and import DotCover coverage with cake and TeamCity?