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:
1010 When I open the coverage report generated with `bundle exec rake minitest`
1111 Then I should see the groups:
1212 | name | coverage | files |
13- | All Files | 80 . 0 % | 1 |
13+ | All Files | 85 . 71 % | 3 |
1414
1515 And I should see the source files:
1616 | name | coverage |
1717 | 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+ """
1827
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 2121# Gotta stash this a-s-a-p, see the CommandGuesser class and i.e. #110 for further info
2222SimpleCov ::CommandGuesser . original_run_command = "#{ $PROGRAM_NAME} #{ ARGV . join ( ' ' ) } "
2323
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!
3131 end
3232end
3333
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 )
3737
38- SimpleCov . set_exit_exception
39- SimpleCov . run_exit_tasks!
38+ SimpleCov . custom_at_exit
4039end
4140
4241# 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