File tree Expand file tree Collapse file tree 4 files changed +62
-13
lines changed
spec/faked_project/minitest Expand file tree Collapse file tree 4 files changed +62
-13
lines changed Original file line number Diff line number Diff line change @@ -10,9 +10,26 @@ Feature:
10
10
When I open the coverage report generated with `bundle exec rake minitest`
11
11
Then I should see the groups:
12
12
| name | coverage | files |
13
- | All Files | 80 . 0 % | 1 |
13
+ | All Files | 85 . 71 % | 3 |
14
14
15
15
And I should see the source files:
16
16
| name | coverage |
17
17
| lib /faked_project /some_class .rb | 80 .0 % |
18
+ | minitest /some_test .rb | 100 .0 % |
19
+ | minitest /test_helper .rb | 75 .0 % |
20
+
21
+ Scenario :
22
+ Given SimpleCov for Minitest is configured with:
23
+ """
24
+ require 'simplecov'
25
+ SimpleCov.start
26
+ """
18
27
28
+ When I open the coverage report generated with `bundle exec ruby -Ilib:minitest minitest/other_test.rb`
29
+ Then I should see the groups:
30
+ | name | coverage | files |
31
+ | All Files | 80 .0 % | 1 |
32
+
33
+ And I should see the source files:
34
+ | name | coverage |
35
+ | lib /faked_project /some_class .rb | 80 .0 % |
Original file line number Diff line number Diff line change
1
+ # frozen_string_literal: true
2
+
3
+ module Minitest
4
+ def self . plugin_simplecov_init ( _options )
5
+ Minitest . after_run do
6
+ SimpleCov . custom_at_exit if SimpleCov . respond_to? ( :custom_at_exit )
7
+ end
8
+ end
9
+ end
Original file line number Diff line number Diff line change 21
21
# Gotta stash this a-s-a-p, see the CommandGuesser class and i.e. #110 for further info
22
22
SimpleCov ::CommandGuesser . original_run_command = "#{ $PROGRAM_NAME} #{ ARGV . join ( ' ' ) } "
23
23
24
- if defined? ( Minitest )
25
- Minitest . after_run do
26
- simplecov_at_exit
27
- end
28
- else
29
- at_exit do
30
- simplecov_at_exit
24
+ module SimpleCov
25
+ def self . custom_at_exit
26
+ # If we are in a different process than called start, don't interfere.
27
+ return if SimpleCov . pid != Process . pid
28
+
29
+ SimpleCov . set_exit_exception
30
+ SimpleCov . run_exit_tasks!
31
31
end
32
32
end
33
33
34
- def simplecov_at_exit
35
- # If we are in a different process than called start, don't interfere.
36
- return if SimpleCov . pid != Process . pid
34
+ at_exit do
35
+ # Exit hook for Minitest defined in Minitest plugin
36
+ next if defined? ( Minitest )
37
37
38
- SimpleCov . set_exit_exception
39
- SimpleCov . run_exit_tasks!
38
+ SimpleCov . custom_at_exit
40
39
end
41
40
42
41
# Autoload config from ~/.simplecov if present
Original file line number Diff line number Diff line change
1
+ require "bundler/setup"
2
+
3
+ begin
4
+ require File . expand_path ( "simplecov_config" , __dir__ )
5
+ rescue LoadError
6
+ warn "No SimpleCov config file found!"
7
+ end
8
+
9
+ require "minitest/autorun"
10
+ require "faked_project/some_class"
11
+
12
+ class OtherTest < Minitest ::Test
13
+ def setup
14
+ @instance = SomeClass . new ( "foo" )
15
+ end
16
+
17
+ def test_reverse
18
+ assert_equal "oof" , @instance . reverse
19
+ end
20
+
21
+ def test_comparison
22
+ assert @instance . compare_with ( "foo" )
23
+ end
24
+ end
You can’t perform that action at this time.
0 commit comments