chatr

Tell RCov to Cov Off

| Comments

Chad and I just released a new version of RCov! This version offers the ability to tell RCov to ignore certain pieces of code. This is useful if you are experiencing an bug in RCov, or if you just plain old disagree with RCov about the coverage status of a particular chunk of code. Here’s an example of implementation:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
class Foo
  def bar
    1 + 2
  end

  #:nocov:
  def quux
    "s" + "hit"
  end
  #:nocov:
end

require 'test/unit'
class FooTest < Test::Unit::TestCase
  def test_bar
    assert_equal 3, Foo.new.bar
  end
end

Running this will show you 100% code coverage. This feature (for now) is pretty simple and does not do anything more than tell RCov to count the code as covered. If this feature takes off, I will spend more time making it smarter about the code and reporting so that you can easily tell the difference.

Comments