gpt4 book ai didi

teamcity - 如何从 Cake 获取 TeamCity 中的 DotCover 覆盖率

转载 作者:行者123 更新时间:2023-12-02 06:50:21 24 4
gpt4 key购买 nike

我最近采用了构建工具 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 正在尝试合并 dotcover 快照,但我认为我没有告诉它这样做。我还发现在部署到 Octopus 任务开始后上传 artifacts/results.dcvr 很奇怪

我已经尝试使用 DotCoverAnalyze 和“result.xml”的 resultPath,但 TeamCity 报告它是一种无效的文件格式。

那么,您如何使用 cake 和 TeamCity 收集和导入 DotCover 覆盖范围?

最佳答案

这就是我目前将 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
});
}
});

关于teamcity - 如何从 Cake 获取 TeamCity 中的 DotCover 覆盖率,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46499050/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com