Skip to content

Getting simplecov to work with minitest's rake task #1032

@zenspider

Description

@zenspider

I've always hated how rake runs tests... it's SO broken. I've been running my own test task via hoe for a very long time and recentlyish ported it over to minitest (see the file here)... it runs in a different manner and as such, the recipe in the simplecov readme doesn't work...

I'm left wondering if this is related to / a variant of #1023 or not...

Here's what I've figured out so far:

with the following recipe at the top of my test:

if ENV['COV'] then
  require 'simplecov'
  SimpleCov.start
end

a manual run works fine:

%  ruby -I... -w test/test_debride.rb

but what the minitest rake task is doing does not:

% ruby -I... -w -e 'require "minitest/autorun"; require "test/test_debride.rb"' -- 

Instead, it runs the report BEFORE the tests start.

If I remove the recipe at the top of the file and manually modify the rake task command:

% ruby -I... -w -e 'require "simplecov"; SimpleCov.start; require "minitest/autorun"; require "test/test_debride.rb"' -- 

then it works again.

AFAICT... this has something to do with the way you're checking for minitest (the guess methods?) or hooking at_exit ... having the minitest/autorun inclusion might be messing it up. We can either try to figure out how to make simplecov happy no matter how tests are run (minitest/autorun before or after), or I can chalk this up to my rake task doing too much too soon and build in support for simplecov to the task itself.

What do you think?

Metadata

Metadata

Assignees

No one assigned

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions