Class: Mutant::Integration::Minitest

Inherits:
Mutant::Integration show all
Defined in:
lib/mutant/integration/minitest.rb

Overview

Minitest integration

Defined Under Namespace

Classes: TestCase

Constant Summary collapse

TEST_FILE_PATTERN =
'./test/**/{test_*,*_test}.rb'
IDENTIFICATION_FORMAT =
'minitest:%s#%s'

Instance Method Summary collapse

Instance Method Details

#all_testsArray<Test>

All tests exposed by this integration

Returns:

  • (Array<Test>)


118
119
120
# File 'lib/mutant/integration/minitest.rb', line 118

def all_tests
  all_tests_index.keys
end

#call(tests) ⇒ Result::Test

Call test integration

rubocop:disable Metrics/MethodLength

Parameters:

  • tests (Array<Tests>)

Returns:

  • (Result::Test)


95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/mutant/integration/minitest.rb', line 95

def call(tests)
  test_cases = tests.map(&all_tests_index.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

#setupself

Setup integration

Returns:

  • (self)


80
81
82
83
84
85
86
# File 'lib/mutant/integration/minitest.rb', line 80

def setup
  Pathname.glob(TEST_FILE_PATTERN)
    .map(&:to_s)
    .each(&world.kernel.method(:require))

  self
end