Module: TestMap::Plugins::Minitest
- Defined in:
- lib/test_map/plugins/minitest.rb,
lib/test_map/plugins/minitest/cache_reporter.rb
Overview
Minitest plugin for TestMap.
Defined Under Namespace
Classes: CacheReporter
Class Method Summary collapse
- .included(_base) ⇒ Object
- .install_cache_reporter ⇒ Object
-
.merge_results(out_file, reporter_results) ⇒ Object
Merge with existing map to preserve mappings for cache-skipped tests.
- .write_results ⇒ Object
Instance Method Summary collapse
Class Method Details
.included(_base) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/test_map/plugins/minitest.rb', line 24 def self.included(_base) TestMap.logger.info 'Registering hooks for Minitest' TestMap.suite_passed = true ::Minitest.after_run { write_results } install_cache_reporter end |
.install_cache_reporter ⇒ Object
32 33 34 |
# File 'lib/test_map/plugins/minitest.rb', line 32 def self.install_cache_reporter ::Minitest.extensions << 'test_map_cache' end |
.merge_results(out_file, reporter_results) ⇒ Object
Merge with existing map to preserve mappings for cache-skipped tests
49 50 51 52 53 54 55 |
# File 'lib/test_map/plugins/minitest.rb', line 49 def self.merge_results(out_file, reporter_results) if File.exist?(out_file) TestMap.reporter.merge(reporter_results, YAML.safe_load_file(out_file)) else reporter_results end end |
.write_results ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/test_map/plugins/minitest.rb', line 36 def self.write_results out_file = "#{Dir.pwd}/#{Config.config[:out_file]}" reporter_results = TestMap.reporter.results # All tests were cache-skipped, existing files are still valid return if reporter_results.empty? full_results = merge_results(out_file, reporter_results) File.write(out_file, full_results.to_yaml) TestMap.cache.write(full_results) if TestMap.suite_passed end |
Instance Method Details
#before_setup ⇒ Object
57 58 59 60 61 62 63 |
# File 'lib/test_map/plugins/minitest.rb', line 57 def before_setup test_file = resolve_test_file raise TestMap::CachedSkip if test_file && TestMap.cache.fresh?(test_file) @recorder = FileRecorder.new.tap(&:trace) super end |
#before_teardown ⇒ Object
65 66 67 68 69 70 71 72 73 74 |
# File 'lib/test_map/plugins/minitest.rb', line 65 def before_teardown super return unless @recorder @recorder.stop TestMap.reporter.add @recorder.results TestMap.suite_passed = false if !passed? && !skipped? end |