OpenCover 中表达式的分支覆盖率
分支机构覆盖范围适用于以下陈述吗?
我期望有一个红色指示器,因为第一个表达式仅具有错误和不正确的测试。
tax.Voided = P_tax.Amount == 1012312870000.42M || P_tax.Amount < 0.00M;
第一个表达式始终为 false,第二个表达式有时为 true:
Does branch coverage work on the following statement?
I expected a red indicator because the first expression only has tests where it is false and not true.
tax.Voided = P_tax.Amount == 1012312870000.42M || P_tax.Amount < 0.00M;
The first expression is always false and the second is sometimes true:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不要将 ReportGenerator 的报告与 OpenCover XML 输出混淆;不过,在 OpenCover 开始开发自己的报告视觉效果之前,ReportGenerator 是目前您能找到的最好的。
这里的问题是报告工具不会仅根据序列覆盖率报告基于分支覆盖率的(红色/绿色)覆盖率。
您将需要查看该方法的分支覆盖率概述(在报告顶部进行了总结) - 要获得更详细的视图,您应该查看该方法的 XML 报告数据,并可能将其与 IL 进行比较(其中OpenCover 从以下位置获取覆盖范围信息)。
注意:OpenCover 不知道你用什么语言编写的代码,它看到的只是已经生成的 IL。
Do not confuse reporting by ReportGenerator with OpenCover XML output; though until the OpenCover starts working on their own reporting visuals ReportGenerator is currently the best you will find for now.
Your problem here is the reporting tool does not report (red/green) coverage based on branch coverage only on sequence coverage.
You will need to look at the overview of branch coverage aginst the method (that is summarised at the top of the report) - for more detail view you should look at the XML report data for the method and perhaps compare that against the IL (where OpenCover gets the coverage information from).
Note: OpenCover does not know what language you wrote the code in all it sees is the IL that has been produced.
如果您的覆盖工具不知道一行中可以有多个有趣的“可覆盖”实体,那么如果该行中的任何覆盖实体被覆盖,您可能会收到一份报告,表明您的行已被覆盖。
据我所知,检测类文件的工具受到这种方式的限制,因为类文件仅包含将类代码与源代码行相关的信息,而不包含部分行。
我们的 Java 测试覆盖率工具(以及我们测试覆盖率工具系列的其他成员)不会检测类代码文件。相反,他们检测源代码,并准确跟踪部分行信息(起始行/列、结束行/列)。
我们的工具在显示声明各个部分的覆盖范围方面不会有任何问题。
If your coverage tool doesn't understand that you can have several interesting "coverable" entities within a line, you will likely get a report that your line is covered if any coverage entity in that line is covered.
Tools that instrument class files are, AFAIK, limited in this way because the class files on only contain information relating class code to source lines, not partial lines.
Our Java Test Coverage tool (and other members of our test coverage tool famility) don't instrument the class code files. Rather, they instrument the source code, and track the partial line information (starting line/column, ending line/column) accurately.
Our tool wouldn't have any trouble showing the coverage on the individual parts of the statement.