.net核心项目代码覆盖率Visual Studio 2017 [英] .net core projects code coverage visual studio 2017

查看:223
本文介绍了.net核心项目代码覆盖率Visual Studio 2017的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Visual Studio Enterprise 2017开发我的.net核心项目。

I am using Visual Studio Enterprise 2017 to develop my .net core projects.

我的解决方案也有一些单元测试项目,我想查看当前的代码覆盖率。

My solution also has some unit test projects and I want to view my current Code coverage.

当我单击测试->分析代码覆盖率->所有测试。我所有的单元测试都运行了,但是在代码覆盖率结果中,它只报告了我的单元测试项目的代码覆盖率,这对我来说没有任何意义。

When I clicked Test -> Analyze Code Coverage -> All tests. All my unit tests ran but in Code Coverage Results it only reported code coverage for my unit test projects which doesn't make any sense to me.

问题1 :你们与我遇到同样的问题吗?有什么解决办法吗?我还需要在VSTS中设置构建定义以报告代码覆盖率。

Question 1: Do you guys experience the same issue with me? Any solution for this? I also need to set up build definition in VSTS to report code coverage.

问题2 :同样,当我右键单击调试单元测试中的1时。它执行我所有的单元测试。这是VS2017中的错误吗?

Question 2: Also when I right clicked to debug 1 of my unit test. It executes ALL of my unit tests. Is this a bug in VS2017?

Update1:​​我找到了这个主题: https://github.com/Microsoft/vstest/issues/597

Update1: I found this topic: https://github.com/Microsoft/vstest/issues/597

推荐答案

即使使用固定版本,我仍然有问题(只能看到测试项目的代码覆盖率,而不是我正在测试的实际项目)。要解决此问题,我从测试项目中删除了< DebugType> Full< / DebugType>

Even with the "fixed" version I had issues (Only able to see code coverage for the test projects, not the actual projects I was testing). To workaround the problem I removed the <DebugType>Full</DebugType> from the test project.

所以,作为摘要:


  1. 将包Microsoft.CodeCoverage(1.0.3)添加到测试项目中。

  1. Add package Microsoft.CodeCoverage (1.0.3) into your test project.

在$ b $的.csproj文件上添加< DebugType> Full< / DebugType> 标记b我们想要查看代码覆盖率值的项目(在< PropertyGroup> 内部),如 vstest github链接)。

Add the <DebugType>Full</DebugType> tag on the .csproj file on the projects we want to see code coverage values (inside <PropertyGroup> as explained on the vstest github link).

我的设置(最小设置?)

My setup (Minimal setup?)


  • xunit(2.3.1)

  • xunit.runner.visualstudio(2.3.1)

  • Microsoft.NET.Test.Sdk(15.3.0)

  • Microsoft.CodeCoverage(1.0.3)

  • Visual Studio Enterprise 2017( 15.4.1)

  • xunit (2.3.1)
  • xunit.runner.visualstudio (2.3.1)
  • Microsoft.NET.Test.Sdk (15.3.0)
  • Microsoft.CodeCoverage (1.0.3)
  • Visual Studio Enterprise 2017 (15.4.1)

这篇关于.net核心项目代码覆盖率Visual Studio 2017的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆