在TeamCity中使用FAKE(F#Make)dotCover覆盖

我有一个FAKE构建脚本,它包含使用DotCoverNUnit3扩展的DotCover覆盖步骤:

let filters = ""

!! (buildDir @@ "/*.UnitTests.dll")
    |> DotCoverNUnit3 (fun p -> 
        { p with
            Output = artifactsDir @@ "NUnitDotCover.snapshot"
            Filters = filters }) nunitOptions

快照生成正确,但覆盖概述不会出现在TeamCity构建中.

然后我在构建快照后尝试调用DotCoverReport:

DotCoverReport (fun p -> 
    { p with 
        Source = artifactsDir @@ "NUnitDotCover.snapshot"
        Output = artifactsDir @@ "NUnitDotCover.xml"
        ReportType = DotCoverReportType.Xml }) true

这会生成预期的XML报告,但同样,覆盖概述不会显示在构建概述页面中.

作为旁注 – 我不确定DotCoverReport方法末尾的布尔参数是什么,在FAKE文档上找不到对它的引用.我试过切换值,但没有什么区别.

有谁知道如何让TeamCity获得DotCover报告?

最佳答案 找到了解决方案.

深入了解TeamCity文档的各个层次后,我找到了这个页面:https://confluence.jetbrains.com/display/TCD9/Manually+Configuring+Reporting+Coverage

其中描述了使用服务消息将TeamCity指向快照的方向.

所以,最后我不需要DotCoverReport,只需要快照:

For dotCover you should send paths to the snapshot file that is generated by the dotCover.exe cover command.

这是我的目标:

let artifactsDir = environVarOrDefault "ARTIFACT_DIR" (currentDirectory @@ "artifacts")

let nunitOptions nUnit3Defaults =
{ NUnit3Defaults with
    TimeOut = TimeSpan.MaxValue
    WorkingDir  = artifactsDir }

Target "TestCoverage" (fun _ ->
    let filters = ""

    !! (buildDir @@ "/*.UnitTests.dll")
        |> DotCoverNUnit3 (fun p -> 
            { p with
                Output = artifactsDir @@ "NUnitDotCover.snapshot"
                Filters = filters }) nunitOptions

    tracefn "##teamcity[importData type='dotNetCoverage' tool='dotcover' path='%s']" (artifactsDir @@ "NUnitDotCover.snapshot") 
)
点赞