Code Coverage exclusion

I've noticed that simple Ruby parts aren't excluded in the live coverage.  "else" and "end" statements for example.  Is there a way to get these included in the code coverage so 100% coverage can be obtained?  I've tried searching docs and the forum and haven't seen anything regarding it.

4 comments
Comment actions Permalink

Hello David,

At the moment RubyMine mostly depends on coverage info provided by rcov gem. In future RubyMine versions we are going to differ source and non-source code lines more accurate according to info provided by RubyMine parser. Probably your problem will be also automatically fixed. You may submit an issue at http://youtrack.jetbrains.net/issues/ruby

0
Comment actions Permalink

Before I file a issue, can you explain it a little bit more?  Take this scenario for example:

  1. Run all specs
  2. Looking at a file I have that I know has 100% coverage, it's shown as "75% lines covered" for the live coverage.
  3. Tools -> Generate Coverage Report
  4. Looking at the file in the browser after rcov generated the info shows 100% coverage with the "else" and "end" statements showing up under the "Lines considered as run by rcov, but not reported by Ruby, look like this,and this: these lines were inferred by rcov (using simple heuristics)." portion of the data.

So by my understanding, if it's using rcov throughout the entire process, shouldn't the love coverage show it at 100% instead of 75%?  I'll go ahead and file a bug but I wanted to make sure I was communicating the right information.

0
Comment actions Permalink


ruby187_rcov_vs_rubymine.png
total lines count = 13

covered lines (according rcov - green) = 6
possibly covered lines (according rcov - grey) = 4

rcov: src lines count = 10
rcov: total file coverage =  10 / 13 = 76,92 %
rcov: code coverage = 7 / 10 = 70 % ( I assume 7 = 6 green lines + grey 'end')

RubyMine: src lines count = 10 (non-src lines doesn't contain green/red gutter)
RubyMine: code coverage = 6 / 10 = 60% (6 green lines)

Here RubyMine and rcov use simple heuristics (based on regexps and finite state machine) to differ src and non-src code and detect a line-comment and two empty lines. RCov report is a bit strange here, by some reason "end" and "def .." lines has different coverage. More over line 8 differs from 12 and 13. So coverage percent is not too accurate both in rcov and RubyMine reports. Here RubyMine can correct a bit coverage data provided by rcov gem and better handle methods/class/blocks declarations start and end.

Looking at the file in the browser after rcov generated the info shows 100% coverage with the "else" and "end" statements showing up under the "Lines considered as run by rcov, but not reported by Ruby, look like this,and this: these lines were inferred by rcov (using simple heuristics).

Most likely in some cases rcov gem heuristics is a bit more accurate.

0

Please sign in to leave a comment.