Skip to content

Commit a999aab

Browse files
committed
Add feature for testing minitest
1 parent 72ec647 commit a999aab

File tree

5 files changed

+57
-6
lines changed

5 files changed

+57
-6
lines changed

features/minitest_basic.feature

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Feature:
2+
3+
Scenario:
4+
Given SimpleCov for Minitest is configured with:
5+
"""
6+
require 'simplecov'
7+
SimpleCov.start
8+
"""
9+
10+
When I open the coverage report generated with `bundle exec rake minitest`
11+
Then I should see the groups:
12+
| name | coverage | files |
13+
| All Files | 80.0% | 1 |
14+
15+
And I should see the source files:
16+
| name | coverage |
17+
| lib/faked_project/some_class.rb | 80.0 % |
18+

lib/simplecov/defaults.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121
# Gotta stash this a-s-a-p, see the CommandGuesser class and i.e. #110 for further info
2222
SimpleCov::CommandGuesser.original_run_command = "#{$PROGRAM_NAME} #{ARGV.join(' ')}"
2323

24-
at_exit do
25-
if defined?(Minitest)
26-
Minitest.after_run do
27-
simplecov_at_exit
28-
end
29-
else
24+
if defined?(Minitest)
25+
Minitest.after_run do
26+
simplecov_at_exit
27+
end
28+
else
29+
at_exit do
3030
simplecov_at_exit
3131
end
3232
end

spec/faked_project/Rakefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,9 @@ Rake::TestTask.new(:test) do |test|
66
test.test_files = FileList["test/**/*_test.rb"].sort
77
test.verbose = true
88
end
9+
10+
Rake::TestTask.new(:minitest) do |test|
11+
test.libs << "minitest"
12+
test.test_files = FileList["minitest/**/*_test.rb"].sort
13+
test.verbose = true
14+
end
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
require "test_helper"
2+
require "faked_project/some_class"
3+
4+
class SomeTest < Minitest::Test
5+
def setup
6+
@instance = SomeClass.new("foo")
7+
end
8+
9+
def test_reverse
10+
assert_equal "oof", @instance.reverse
11+
end
12+
13+
def test_comparison
14+
assert @instance.compare_with("foo")
15+
end
16+
end
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
require "bundler/setup"
2+
3+
# We're injecting simplecov_config via aruba in cucumber here
4+
# depending on what the test case is...
5+
begin
6+
require File.join(File.dirname(__FILE__), "simplecov_config")
7+
rescue LoadError
8+
$stderr.puts "No SimpleCov config file found!"
9+
end
10+
11+
require "minitest/autorun"

0 commit comments

Comments
 (0)