Class: Selective::Ruby::Minitest::RunnerWrapper
- Inherits:
-
Object
- Object
- Selective::Ruby::Minitest::RunnerWrapper
- Defined in:
- lib/selective/ruby/minitest/runner_wrapper.rb
Defined Under Namespace
Classes: TestManifestError
Constant Summary collapse
- FRAMEWORK =
"minitest"- DEFAULT_TEST_DIR =
"test"
Instance Attribute Summary collapse
-
#connection_lost ⇒ Object
Returns the value of attribute connection_lost.
-
#minitest_args ⇒ Object
readonly
Returns the value of attribute minitest_args.
-
#reporter ⇒ Object
readonly
Returns the value of attribute reporter.
-
#targeted_test_ids ⇒ Object
readonly
Returns the value of attribute targeted_test_ids.
-
#test_case_callback ⇒ Object
readonly
Returns the value of attribute test_case_callback.
-
#test_ids ⇒ Object
readonly
Returns the value of attribute test_ids.
-
#test_map ⇒ Object
readonly
Returns the value of attribute test_map.
Instance Method Summary collapse
- #base_test_path ⇒ Object
- #exit_status ⇒ Object
- #finish ⇒ Object
- #framework ⇒ Object
- #framework_version ⇒ Object
-
#initialize(args, test_case_callback) ⇒ RunnerWrapper
constructor
A new instance of RunnerWrapper.
- #manifest ⇒ Object
- #remove_test_case_result(test_case_id) ⇒ Object
- #run_test_cases(test_case_ids) ⇒ Object
- #wrapper_version ⇒ Object
Constructor Details
#initialize(args, test_case_callback) ⇒ RunnerWrapper
Returns a new instance of RunnerWrapper.
17 18 19 20 21 22 23 24 |
# File 'lib/selective/ruby/minitest/runner_wrapper.rb', line 17 def initialize(args, test_case_callback) @test_case_callback = test_case_callback @targeted_test_ids, @minitest_args, wrapper_config_hash = parse_args(args) Selective::Ruby::Minitest::Monkeypatches.apply(wrapper_config_hash) configure end |
Instance Attribute Details
#connection_lost ⇒ Object
Returns the value of attribute connection_lost.
12 13 14 |
# File 'lib/selective/ruby/minitest/runner_wrapper.rb', line 12 def connection_lost @connection_lost end |
#minitest_args ⇒ Object (readonly)
Returns the value of attribute minitest_args.
11 12 13 |
# File 'lib/selective/ruby/minitest/runner_wrapper.rb', line 11 def minitest_args @minitest_args end |
#reporter ⇒ Object (readonly)
Returns the value of attribute reporter.
11 12 13 |
# File 'lib/selective/ruby/minitest/runner_wrapper.rb', line 11 def reporter @reporter end |
#targeted_test_ids ⇒ Object (readonly)
Returns the value of attribute targeted_test_ids.
11 12 13 |
# File 'lib/selective/ruby/minitest/runner_wrapper.rb', line 11 def targeted_test_ids @targeted_test_ids end |
#test_case_callback ⇒ Object (readonly)
Returns the value of attribute test_case_callback.
11 12 13 |
# File 'lib/selective/ruby/minitest/runner_wrapper.rb', line 11 def test_case_callback @test_case_callback end |
#test_ids ⇒ Object (readonly)
Returns the value of attribute test_ids.
11 12 13 |
# File 'lib/selective/ruby/minitest/runner_wrapper.rb', line 11 def test_ids @test_ids end |
#test_map ⇒ Object (readonly)
Returns the value of attribute test_map.
11 12 13 |
# File 'lib/selective/ruby/minitest/runner_wrapper.rb', line 11 def test_map @test_map end |
Instance Method Details
#base_test_path ⇒ Object
66 67 68 |
# File 'lib/selective/ruby/minitest/runner_wrapper.rb', line 66 def base_test_path "./#{default_test_glob.split("/").first}" end |
#exit_status ⇒ Object
70 71 72 |
# File 'lib/selective/ruby/minitest/runner_wrapper.rb', line 70 def exit_status failures.reject(&:skipped?).length.zero? ? 0 : 1 end |
#finish ⇒ Object
74 75 76 77 78 79 |
# File 'lib/selective/ruby/minitest/runner_wrapper.rb', line 74 def finish ::Minitest.selective_postrun(reporter, minitest_args) # This usually happens in at_exit defined in autorun. ::Minitest.class_variable_get(:@@after_run).reverse_each(&:call) end |
#framework ⇒ Object
81 82 83 |
# File 'lib/selective/ruby/minitest/runner_wrapper.rb', line 81 def framework RunnerWrapper::FRAMEWORK end |
#framework_version ⇒ Object
85 86 87 |
# File 'lib/selective/ruby/minitest/runner_wrapper.rb', line 85 def framework_version ::Minitest::VERSION end |
#manifest ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/selective/ruby/minitest/runner_wrapper.rb', line 26 def manifest raise_test_manifest_error("No test cases found") if test_ids.empty? ids = @targeted_test_ids.any? ? @targeted_test_ids : test_ids { "test_cases" => ids.map do |test_id| test = test_map[test_id] { id: test_id, file_path: test[:file_path], run_time: 0.0 } end } end |
#remove_test_case_result(test_case_id) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/selective/ruby/minitest/runner_wrapper.rb', line 51 def remove_test_case_result(test_case_id) test = test_map[test_case_id] return unless test result = summary_reporter.results.detect do |r| r.source_location.first.gsub(root_path, "") == test[:file_path] && r.name == test[:method_name] end return unless result result.failures = [] summary_reporter.results.delete(result) end |
#run_test_cases(test_case_ids) ⇒ Object
42 43 44 45 46 47 48 49 |
# File 'lib/selective/ruby/minitest/runner_wrapper.rb', line 42 def run_test_cases(test_case_ids) test_case_ids.map do |test_id| klass, method_name = get_test_from_map(test_id) real_time = time { klass.run_one_method(klass, method_name, reporter) } foo = format_test_case(test_id, klass, method_name, real_time) test_case_callback.call(foo) end end |
#wrapper_version ⇒ Object
89 90 91 |
# File 'lib/selective/ruby/minitest/runner_wrapper.rb', line 89 def wrapper_version ::Minitest::VERSION end |