简体   繁体   English

Visual Studio 2013和TFS 2013中更改代码的代码覆盖率

[英]Code Coverage of Changed Code in Visual Studio 2013 & TFS 2013

Visual Studio and TFS have both tools to collect and report on code coverage for a project or solution. Visual Studio和TFS都有两种工具来收集和报告项目或解决方案的代码覆盖率。 What we're interested in knowing, though, is how much of the changed code has been covered by tests. 但是,我们感兴趣的是,测试涵盖了多少已更改的代码。 We'd like to be able to identify a baseline changeset in TFS and then get a report on what code was changed in the current build, what portion of it was covered by testing, and most importantly, what portion wasn't. 我们希望能够在TFS中识别基线变更集,然后获得有关当前构建中哪些代码已更改的报告,其中哪些部分由测试覆盖,最重要的是,哪些部分不是。 As far as I can see, the code coverage reports and analysis in Visual Studio don't take into consideration what code has changed--they only tell you about code coverage for the entire project or solution. 据我所知,Visual Studio中的代码覆盖率报告和分析没有考虑代码的变化 - 它们只告诉您整个项目或解决方案的代码覆盖率。

Unfortunately, there's no out of the box functionality from TFS or Visual Studio for getting what you want. 不幸的是,TFS或Visual Studio没有开箱即用的功能来获得你想要的东西。

The Code Churn and Code Coverage perspectives from the TFS data warehouse won't help much as the code churn perspective only tracks lines of code that changed, not which methods were changed. 来自TFS数据仓库的代码流失和代码覆盖率视角将无济于事,因为代码流失视角仅跟踪已更改的代码行,而不是更改哪些方法。

Looking at an alternate option, you might be able to get what you're after using SonarQube's differential views but they are date based, not changeset/commit based. 查看备用选项,您可能能够获得使用SonarQube 差异视图后的内容,但它们基于日期,而不是基于变更集/提交。 Plus the SCM plugin needed hasn't been tested against TF Version Control so I don't know if it will work (I haven't tried it myself). 此外,所需的SCM插件尚未针对TF Version Control进行测试,因此我不知道它是否可行(我自己没有尝试过)。 If you're using git with TFS then it should work fine, you'll just have to go through the hassle of setting it all up. 如果你正在使用带有TFS的git那么它应该可以正常工作,你只需要经历设置它的麻烦。

If you are looking at alternatives, NDepend can provide this feature and it has pretty good integration with Visual Studio . 如果您正在寻找替代方案,NDepend可以提供此功能,并且它与Visual Studio有很好的集成

NDepend lets you compare two versions of a codebase. NDepend允许您比较代码库的两个版本。 You are able to choose what the baseline is, for example a specific build from last release or just the previous build. 您可以选择基线的内容,例如上一版本中的特定版本或上一版本。 You can then query against the diff. 然后,您可以查询diff。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM