Class: Evilution::Integration::TestUnit

Inherits:
Base
  • Object
show all
Defined in:
lib/evilution/integration/test_unit.rb

Overview

Test::Unit integration. Decomposed under lib/evilution/integration/test_unit/ mirroring the RSpec integration’s layout. This class is the orchestrator: it wires the framework loader, dispatcher, subject-class registry, test-file resolver, and result builder. The class is registered under Evilution::Runner::INTEGRATIONS and reachable via the ‘–integration test-unit` CLI flag.

Defined Under Namespace

Modules: Dispatcher, ResultBuilder, SubjectClassRegistry Classes: FrameworkLoader, TestFileResolver

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#call

Constructor Details

#initialize(test_files: nil, hooks: nil, fallback_to_full_suite: false, spec_selector: nil) ⇒ TestUnit

Returns a new instance of TestUnit.



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/evilution/integration/test_unit.rb', line 53

def initialize(test_files: nil, hooks: nil, fallback_to_full_suite: false, spec_selector: nil)
  require_relative "test_unit/framework_loader"
  require_relative "test_unit/subject_class_registry"
  require_relative "test_unit/dispatcher"
  require_relative "test_unit/test_file_resolver"
  require_relative "test_unit/result_builder"
  @framework_loader = FrameworkLoader.new
  @file_resolver = TestFileResolver.new(
    test_files: test_files,
    spec_selector: spec_selector || Evilution::SpecSelector.new(spec_resolver: self.class.spec_resolver),
    fallback_to_full_suite: fallback_to_full_suite
  )
  @crash_detector = nil
  super(hooks: hooks)
end

Class Method Details

.baseline_optionsObject



30
31
32
33
34
35
36
# File 'lib/evilution/integration/test_unit.rb', line 30

def self.baseline_options
  {
    runner: baseline_runner,
    spec_resolver: spec_resolver,
    fallback_dir: "test"
  }
end

.baseline_runnerObject



17
18
19
# File 'lib/evilution/integration/test_unit.rb', line 17

def self.baseline_runner
  ->(test_file) { run_baseline_test_file(test_file) }
end

.baseline_test_files(test_file) ⇒ Object



49
50
51
# File 'lib/evilution/integration/test_unit.rb', line 49

def self.baseline_test_files(test_file)
  File.directory?(test_file) ? Dir.glob(File.join(test_file, "**/*_test.rb")) : [test_file]
end

.run_baseline_test_file(test_file) ⇒ Object



38
39
40
41
42
43
44
45
46
47
# File 'lib/evilution/integration/test_unit.rb', line 38

def self.run_baseline_test_file(test_file)
  require_relative "test_unit/framework_loader"
  require_relative "test_unit/subject_class_registry"
  require_relative "test_unit/dispatcher"
  FrameworkLoader.new.call
  new_classes = SubjectClassRegistry.newly_loaded do
    baseline_test_files(test_file).each { |f| load(File.expand_path(f)) }
  end
  Dispatcher.call(new_classes, name: "evilution baseline").passed?
end

.spec_resolverObject

SpecResolver tuned for the dominant Test::Unit layout: tests live under test/, named with the _test.rb suffix (the same convention Minitest uses). Rails plugins on the test-unit gem (e.g. kaminari-core) follow this layout. The test/test_<name>.rb prefix-style convention is rare enough in practice that we defer support to a follow-up if a project surfaces needing it.



26
27
28
# File 'lib/evilution/integration/test_unit.rb', line 26

def self.spec_resolver
  Evilution::SpecResolver.new(test_dir: "test", test_suffix: "_test.rb", request_dir: "integration")
end