.NET - 确定哪些测试用例覆盖的方法测试、方法、NET

2023-09-06 18:41:36 作者:姐是性感不是骚

我想知道,盖一个特定的方法测试。然而,NCover不提供此信息。我不想使用VSTS作为我的code不是在TFS。 有什么办法/工具来做到这一点。NET中?

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?

推荐答案

从根本上说什么,你需要做的是为每个测试运行测试覆盖率工具一次,生产该测试的覆盖载体。如果你有上百次试验,可以为每个测试单独收集覆盖。

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.

那么,如果覆盖向量N覆盖的方法,试验N引起的覆盖面。

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

我不知道是否NCover如果/ NCover如何交叉参考回对应于该方法的源$ C ​​$ C行的范围。

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.

有关我们的 C#的测试覆盖率工具的instrumenter工具生产线号范围为每个覆盖测试点,并有在每一方法的起始插入一个测试点。所以,如果你知道一个文件的方法的行号,你可以在技术上找到入口覆盖点,因此该行的范围,构成了该法,因此,所有的方法测试覆盖点。有了这样一个清单是简单的计算测试覆盖率向量是否命中的那些点。因此,我们的工具能够提供此数据所必需的信息,虽然它没有很好的记载。你可以 向我们提供进一步的文件,或帮助做这个。

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.