热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

.NET-确定哪些测试用例涵盖了一个方法-.NET-determiningwhichtestcasescoveredamethod

Iwanttoknowtheteststhatcoveraparticularmethod.However,NCoverdoesnotprovidethisinfor

I want to know the tests that cover a particular method. However, NCover does not provide this information. I dont want to use VSTS as my code is not in TFS. Is there any way/tool to do that in .NET?

我想知道涵盖特定方法的测试。但是,NCover不提供此信息。我不想使用VSTS,因为我的代码不在TFS中。在.NET中有没有办法/工具呢?

2 个解决方案

#1


1  

Fundamentally what you have to do is to run your test coverage tool once for each test, producing a coverage vector for that test. If you have hundreds of tests, you can collect coverage for each test separately.

从根本上说,您需要为每个测试运行一次测试覆盖率工具,为该测试生成覆盖矢量。如果您有数百个测试,则可以分别为每个测试收集覆盖率。

Then if coverage vector N covers a method, test N caused that coverage.

然后,如果覆盖矢量N覆盖方法,则测试N导致该覆盖。

I don't know if NCover if/how NCover can cross reference back to the range of lines that correspond to the source code of the method.

我不知道NCover是否/如何将NCover交叉引用回到与方法源代码对应的行的范围。

For our C# Test Coverage Tool, the instrumenter tool produces line number ranges for each coverage test point, and there is a test point inserted at the start of every method. So if you know the line number of a method in a file, you can technically locate the entry coverage point, thus the line range that makes up the method, thus all test coverage points in the method. With such a list it is straightforward to compute whether a test coverage vector has hit those points. So, our tool has the information necessary to provide this data, although it isn't well documented. You could ask us for further documentation or help doing this.

对于我们的C#测试覆盖率工具,仪器工具为每个覆盖测试点生成行号范围,并在每个方法的开头插入一个测试点。因此,如果您知道文件中方法的行号,则可以在技术上定位条目覆盖点,从而定义构成方法的行范围,从而确定方法中的所有测试覆盖点。使用这样的列表,可以直接计算测试覆盖率向量是否已经达到这些点。因此,我们的工具具有提供此数据所需的信息,尽管没有详细记录。您可以向我们索取进一步的文档或帮助您做到这一点。

#2


0  

dotCover I believe provides that sort of support in the UI but I am not so sure if this information is available from a build machine.

dotCover我相信在UI中提供了这种支持,但我不确定这些信息是否可以从构建机器获得。

OpenCover has work in progress on one of its forks - This is one of the original aims of the project and has driven the design of OpenCover to reach this aim with a single run of the tests - stay tuned...

OpenCover正在开发其中一个分支 - 这是该项目的最初目标之一,并推动OpenCover的设计通过一次测试实现这一目标 - 敬请期待...

Finally as Ira mentions you can run a test individually and get coverage (using most coverage tools such as NCover, PartCover, OpenCover, ...) from a single test executed with NUnit/MSTest (insert test tool of choice) however you will also get coverage of anything that happened in any setup/teardown actions as well.

最后,当Ira提到您可以单独运行测试并使用NUnit / MSTest(选择的插入测试工具)执行的单个测试获得覆盖(使用大多数覆盖工具,如NCover,PartCover,OpenCover,...)但是您也将了解任何设置/拆卸操作中发生的任何事情。


推荐阅读
author-avatar
我不是咸鱼仔
这个家伙很懒,什么也没留下!
Tags | 热门标签
RankList | 热门文章
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有