.net核心项目代码覆盖率Visual Studio 2017

编程入门 行业动态 更新时间:2024-10-19 05:30:01
本文介绍了核心项目代码覆盖率Visual Studio 2017的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

I am using Visual Studio Enterprise 2017 to develop my 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:​​我找到了这个主题: github/Microsoft/vstest/issues/597

Update1: I found this topic: github/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.

所以,作为摘要:

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

  • 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

    本文发布于:2023-11-14 09:54:08,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1586899.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:覆盖率   核心   代码   项目   net

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!