class Mutant::Integration::Minitest

Minitest integration

Constants

IDENTIFICATION_FORMAT
TEST_FILE_PATTERN

Public Instance Methods

all_tests() click to toggle source

All tests exposed by this integration

@return [Array<Test>]

# File lib/mutant/integration/minitest.rb, line 118
def all_tests
  all_tests_index.keys
end
call(tests) click to toggle source

Call test integration

@param [Array<Tests>] tests

@return [Result::Test]

rubocop:disable Metrics/MethodLength

# File lib/mutant/integration/minitest.rb, line 95
def call(tests)
  test_cases = tests.map(&all_tests_index.public_method(:fetch))
  start      = timer.now

  reporter = ::Minitest::SummaryReporter.new($stdout)

  reporter.start

  test_cases.each do |test|
    break unless test.call(reporter)
  end

  reporter.report

  Result::Test.new(
    passed:  reporter.passed?,
    runtime: timer.now - start
  )
end
setup() click to toggle source

Setup integration

@return [self]

# File lib/mutant/integration/minitest.rb, line 80
def setup
  Pathname.glob(TEST_FILE_PATTERN)
    .map(&:to_s)
    .each(&world.kernel.public_method(:require))

  self
end

Private Instance Methods

all_test_cases() click to toggle source
# File lib/mutant/integration/minitest.rb, line 139
def all_test_cases
  ::Minitest::Runnable
    .runnables
    .select(&method(:allow_runnable?))
    .flat_map(&method(:test_case))
end
all_tests_index() click to toggle source
# File lib/mutant/integration/minitest.rb, line 125
def all_tests_index
  all_test_cases.each_with_object({}) do |test_case, index|
    index[construct_test(test_case)] = test_case
  end
end
allow_runnable?(klass) click to toggle source
# File lib/mutant/integration/minitest.rb, line 146
def allow_runnable?(klass)
  !klass.equal?(::Minitest::Runnable)
end
construct_test(test_case) click to toggle source
# File lib/mutant/integration/minitest.rb, line 132
def construct_test(test_case)
  Test.new(
    id:          test_case.identification,
    expressions: test_case.expressions(expression_parser)
  )
end
test_case(runnable) click to toggle source
# File lib/mutant/integration/minitest.rb, line 150
def test_case(runnable)
  runnable.runnable_methods.map { |method| TestCase.new(runnable, method) }
end