Class: Binpacker::MinitestDiscovery

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

Instance Method Summary collapse

Methods inherited from TestDiscovery

#initialize

Constructor Details

This class inherits a constructor from Binpacker::TestDiscovery

Instance Method Details

#enumerateObject



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

def enumerate
  require "minitest"
  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