Rcov 覆盖范围因 -xrefs 而发生巨大变化
我当前的 Ruby on Rails 项目通过 rcov 进行测试(具体来说,相关性 rcov,并且我们有相当高的标准(如果代码覆盖率小于 95%,则构建失败)。
我们使用以下命令来测试这一点:
rcov_cmd = "rcov --rails --text-summary \
--include #{included_dirs} \
--exclude #{excluded_dirs} \
--aggregate #{coverage_dir}/coverage.data \
--output #{coverage_dir} \
今天我在 rcov Homever 报告中发现了一些注册为绿色(已运行)的代码,我可以证明这一点。代码没有运行(我在函数的开头引发了一个异常,并且我的单元测试通过了)
我做了一些研究,发现了 rcov 的 --xrefs 标志,我认为它会添加每行的所有调用者rcov 报告。
我将 rcov 命令更改为:(
rcov_cmd = "rcov --rails --text-summary --xrefs \
--include #{included_dirs} \
--exclude #{excluded_dirs} \
--aggregate #{coverage_dir}/coverage.data \
--output #{coverage_dir} \
标志)。
我的测试覆盖率从 96% 变为 48%。
注意添加的 --xrefs -xrefs 改变 rcov 的分析方式(我认为它只会收集调用点信息)。这与第一个命令有何不同/更好? (我已经看到,如果单元测试失败,单元测试覆盖率会下降,并且我知道如果运行中出现错误,覆盖率百分比也会下降,但对我来说看起来不错)
My current Ruby on Rails project does testing via rcov (specifically, relevance rcov, and we have a pretty high standard (we fail the build if we have < 95% code coverage).
We use the following command to test this:
rcov_cmd = "rcov --rails --text-summary \
--include #{included_dirs} \
--exclude #{excluded_dirs} \
--aggregate #{coverage_dir}/coverage.data \
--output #{coverage_dir} \
Today I found some code that registers green (having run) in the rcov reports. Homever, I can prove that this code isn't getting run (I raise an exception in the beginning of the function, and my unit tests pass)
I did some research and found the --xrefs flag for rcov, which I thought would add all the callers for each line in the rcov reports.
I changed the rcov command to:
rcov_cmd = "rcov --rails --text-summary --xrefs \
--include #{included_dirs} \
--exclude #{excluded_dirs} \
--aggregate #{coverage_dir}/coverage.data \
--output #{coverage_dir} \
(notice the added --xrefs
flag).
Instead of additional callsite information, I instead have my test coverage go from 96% to 48%.
Does --xrefs change the kind of analysis how rcov does? (I thought it would just gather callsite information). How is this different / better from the first command?
(I've seen the unit test coverage drop if there's a failing unit test, and I know that the coverage percentage can drop if there's an error in the run, but it looks good to me)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
来自 rcov 手册:
来自 Rcov CallSiteAnalyzer 类
通过此分析 rcov 可以提供更准确的覆盖信息,但执行时间较长。
From rcov manual:
From Rcov CallSiteAnalyzer Class
Having this analyze rcov can provide more accurate coverage information in cost of longer execution.