c# - Visual Studio Code Coverage 在 vNext 项目中过时了吗?

标签 c# visual-studio code-coverage visual-studio-2015

因为嵌入到 Visual Studio 中的代码覆盖实用程序(vstest.console.execodecoverage.exe)分析二进制文件,例如 .dll.exe 文件,这些工具是否仍可用于 vNext 项目(因为它们不生成二进制文件)?

我正在尝试使用 vNext 类库对解决方案运行代码覆盖率,但我能够生成的唯一信息是 xUnit .dll 文件,而不是我的项目。

最佳答案

我们的团队能够使用 OpenCover 为 vNext 解决方案生成代码覆盖率文件。这需要一些开销,因为 OpenCover 会逐个项目地分析项目,因此您需要编写脚本来循环解决方案中的项目,运行 OpenCover,然后合并覆盖率文件。

以下是我们在脚本中所做的示例,以防有人想复制它:

我们遍历每个项目并调用 DNX 引擎和 OpenCover 来为该项目生成覆盖。

foreach($projectFile in $projectFiles)
{
    $project=$projectFile.Directory.Name

    $buildCommands=$buildCommands+$projectFile.Directory.FullName
    $testPoject = //Path//To//Test//Projects
    if(Test-Path $testPoject)
    {
        _Verbose "$testPoject exists for $project"
        $testCommand = "$OpenCoverUtil -register:user ""-excludebyfile:*\*.gen.cs"" ""-target:$DnxPath\dnx.exe "" ""-targetargs: $testPoject\project.json test"" ""-output:$Outpath\CS\$project.coverage.xml"" -skipautoprops -returntargetcode -filter:""+[$project*]*"""
        _Verbose $testCommand
        $testCommands=$testCommands+$testCommand
    }
}

关于c# - Visual Studio Code Coverage 在 vNext 项目中过时了吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30333886/

相关文章:

visual-studio - Visual Studio 2022 无法构建任何项目

c++ - Windows环境下的Chromium调试

c# - 迭代不同数据类型的列表?

c# - 为什么Invoke BeginInvoke和EndInvoke在内部类密封的情况下是虚的?

c# - Resharper 9 文件布局 : defining sort order when sorting by access modifier not possible?

c++ - Bjam 用于 gcov 覆盖分析?

java - 运行 Web 应用程序时,IntelliJ 的代码覆盖率显示为 0%

c# - 绑定(bind) IsPaneOpen 解决 bool 属性问题

c# - 如何在C#应用程序中进行备份?

python - 如何将覆盖率结果与 tox 结合起来?