Skip to content

Commit

Permalink
Add feature for testing minitest
Browse files Browse the repository at this point in the history
  • Loading branch information
adam12 committed Dec 1, 2019
1 parent 72ec647 commit a999aab
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 6 deletions.
18 changes: 18 additions & 0 deletions features/minitest_basic.feature
@@ -0,0 +1,18 @@
Feature:

Scenario:
Given SimpleCov for Minitest is configured with:
"""
require 'simplecov'
SimpleCov.start
"""

When I open the coverage report generated with `bundle exec rake minitest`
Then I should see the groups:
| name | coverage | files |
| All Files | 80.0% | 1 |

And I should see the source files:
| name | coverage |
| lib/faked_project/some_class.rb | 80.0 % |

12 changes: 6 additions & 6 deletions lib/simplecov/defaults.rb
Expand Up @@ -21,12 +21,12 @@
# Gotta stash this a-s-a-p, see the CommandGuesser class and i.e. #110 for further info
SimpleCov::CommandGuesser.original_run_command = "#{$PROGRAM_NAME} #{ARGV.join(' ')}"

at_exit do
if defined?(Minitest)
Minitest.after_run do
simplecov_at_exit
end
else
if defined?(Minitest)
Minitest.after_run do
simplecov_at_exit
end
else
at_exit do
simplecov_at_exit
end
end
Expand Down
6 changes: 6 additions & 0 deletions spec/faked_project/Rakefile
Expand Up @@ -6,3 +6,9 @@ Rake::TestTask.new(:test) do |test|
test.test_files = FileList["test/**/*_test.rb"].sort
test.verbose = true
end

Rake::TestTask.new(:minitest) do |test|
test.libs << "minitest"
test.test_files = FileList["minitest/**/*_test.rb"].sort
test.verbose = true
end
16 changes: 16 additions & 0 deletions spec/faked_project/minitest/some_test.rb
@@ -0,0 +1,16 @@
require "test_helper"
require "faked_project/some_class"

class SomeTest < Minitest::Test
def setup
@instance = SomeClass.new("foo")
end

def test_reverse
assert_equal "oof", @instance.reverse
end

def test_comparison
assert @instance.compare_with("foo")
end
end
11 changes: 11 additions & 0 deletions spec/faked_project/minitest/test_helper.rb
@@ -0,0 +1,11 @@
require "bundler/setup"

# We're injecting simplecov_config via aruba in cucumber here
# depending on what the test case is...
begin
require File.join(File.dirname(__FILE__), "simplecov_config")
rescue LoadError
$stderr.puts "No SimpleCov config file found!"
end

require "minitest/autorun"

0 comments on commit a999aab

Please sign in to comment.