【问题标题】:code coverage highlighting in .net core visual studio.net core Visual Studio 中的代码覆盖率高亮显示
【发布时间】:2016-11-08 06:09:17
【问题描述】:

我正在使用带有 .NET Core 项目的 Visual Studio 2015。我已经正确设置了所有单元测试,测试运行良好,执行良好。

唯一缺少的是代码覆盖率突出显示。它曾经与我的 .Net4.5 应用程序一起使用。我错过了什么吗?

我将 XUnit 与 .NET Core 一起使用。我加了Microsoft.CodeCoverage,但是好像没有什么区别。

这是我的 project.json:

{
  "version": "1.0.0-*",
  "buildOptions": {
    "debugType": "portable",
    "copyToOutput": {
      "include": [ "xunit.runner.json" ]
    }
  },
  "dependencies": {
    "System.Runtime.Serialization.Primitives": "4.1.1",
    "xunit": "2.1.0",
    "dotnet-test-xunit": "2.2.0-preview2-build1029",
    "ClanService": { "target": "project" },
    "Utilities": { "target": "project" },
    "UnitTests.Configuration": { "target": "project" },
    "Microsoft.CodeCoverage": "1.0.2"
  },
  "testRunner": "xunit",
  "frameworks": {
    "netcoreapp1.0": {
      "dependencies": {
        "Microsoft.NETCore.App": {
          "type": "platform",
          "version": "1.0.1"
        }
      },
      "imports": [
        "dotnet5.4",
        "portable-net451+win8"
      ]
    }
  }
}

还有其他人对此有任何运气吗?

【问题讨论】:

  • 您的 Visual Studio 版本是多少?只有企业版具有代码覆盖率突出显示。
  • 我在企业版
  • 将您的 debugtype 构建选项从 portable 更改为 full 应该可以解决您的问题。
  • @nulltoken 你是个天才!将此作为答案发布,我会投票一千次。 :)
  • @l3utterfly 完成 ;-)

标签: c# unit-testing visual-studio-2015 asp.net-core


【解决方案1】:

从 .NET Core LTS 1.0.3 开始,将您的 debugtype 构建选项从 portable 更改为 full 应该可以解决您的问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-01-25
    • 2023-03-08
    • 2018-02-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多