Question

This is my class which returns the multiplication of parameters

class NetAssetValue

def calculate_net_asset_value(number_of_shares, price)

    number_of_shares * price
  end

end

And this is my Test

require 'net_asset_value'

require 'test/unit'

class NetAssetValueTest  < Test::Unit::TestCase

  def setup

    @asset = NetAssetValue.new

  end


  def test_calculate_net_asset_value_for_a_symbol

    assert_equal(100, @asset.calculate_net_asset_value(20,5))

  end

end

I am using SimpleCov 0.7.1. The coverage report says the one line in the method is not covered though it is being covered.

It says the coverage is 66.67% and the line

number_of_shares * price

is not covered But when I debug in RubyMine and place a breakpoint on that line it is being hit.

Need Help on this. Thank you.

Was it helpful?

Solution

You can't use Simplecov from within Rake::TestTask since that task runs the tests in a separate process. See https://github.com/colszowka/simplecov/issues/88.

EDIT

To clarify: You can certainly use SimpleCov by using a Rakefile, but you can't start (SimpleCov.start) it in the Rakefile. You need to do that in the test, e.g. in your test helper. Keep in mind that SimpleCov.start must be called before requiring your production code.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top