开发者

Rcov coverage changes drastically with -xrefs

My current Ruby on Rails project does testing via rcov (specifically, relevance rcov, and we have a pretty high standard (we fail the bui开发者_StackOverflow中文版ld 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)


From rcov manual:

--[no-]callsites
    Show callsites in generated XHTML report. (somewhat slower; disabled by default)
--[no-]xrefs
    Generate fully cross-referenced report. (includes --callsites)

From Rcov CallSiteAnalyzer Class

A CallSiteAnalyzer can be used to obtain information about:

    * where a method is defined ("defsite")
    * where a method was called from ("callsite")

Having this analyze rcov can provide more accurate coverage information in cost of longer execution.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜