Class: Binpacker::MinitestDiscovery

Inherits:
TestDiscovery show all
Defined in:
lib/binpacker/test_discovery.rb,
sig/binpacker/test_discovery.rbs

Instance Method Summary collapse

Methods inherited from TestDiscovery

#initialize

Constructor Details

This class inherits a constructor from Binpacker::TestDiscovery

Instance Method Details

#enumerateArray[Binpacker::Test]

Returns:



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/binpacker/test_discovery.rb', line 71

def enumerate
  begin
    require "minitest"
  rescue LoadError
    raise DiscoveryError,
      "minitest is not available. binpacker supports rspec and minitest; " \
      "test-unit and other frameworks are not supported."
  end
  add_project_load_paths
  def Minitest.autorun; end
  Minitest.seed = 42

  tests = []
  glob_files.each do |file|
    begin
      klasses_before = Minitest::Runnable.runnables.dup
      load File.expand_path(file)

      (Minitest::Runnable.runnables - klasses_before).each do |klass|
        klass.runnable_methods.each do |method_name|
          tests << Test.new(file: file, name: "#{klass}##{method_name}")
        end
      end
    rescue => e
      $stderr.puts "minitest discovery: failed to load #{file}: #{e.message}"
    end
  end
  tests
end