views:

129

answers:

0

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)