0

I integrated SimpleCov into my Ruby project (simple Ruby Gem project, no framework), which uses MiniTest for testing.

Here is test_helper.rb:

  require 'simplecov'
  SimpleCov.start

  require 'minitest/autorun'

All my test files have require 'test_helper.rb'.

Running all the tests (either from RubyMine or with bundle exec rake) works and the HTML report is created.

However, it contains the coverage for... one of my test classes? I would expect to see a coverage report of all the classes called by the tests (which are under the standard /lib folder).

Here is the generaged report:

https://user-images.githubusercontent.com/6305156/80513538-df68d080-8987-11ea-9858-43a3a2673e31.png

The link to the project: https://github.com/ruby-ee/ruby-stream-api/tree/10 It's a simple, barely started, Ruby Gem.

Any help is greatly appreciated. Thanks!

amihaiemil
  • 623
  • 8
  • 19

1 Answers1

1

I managed to fix it. The SimpleCov documentation states that SimpleCov must be required and SimpleCov.start must be issued before any of the application code is required!

I had a require directive in my *.gemfile, therefore I had to add

require 'simplecov'
SimpleCov.start do     # ommit test classes from the report
  add_filter 'test'
end

right there, instead of the test_helper.rb.

amihaiemil
  • 623
  • 8
  • 19