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,minitest}/**/{test_*,*_test}.rb'
IDENTIFICATION_FORMAT =
'minitest:%s#%s'

Instance Method Summary collapse

Instance Method Details

#all_testsArray<Test> Also known as: available_tests

All tests exposed by this integration

Returns:

  • (Array<Test>)


136
# File 'lib/mutant/integration/minitest.rb', line 136

def all_tests = all_tests_index.keys

#call(tests) ⇒ Result::Test

Call test integration

rubocop:disable Metrics/MethodLength

Parameters:

  • tests (Array<Tests>)

Returns:

  • (Result::Test)


111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/mutant/integration/minitest.rb', line 111

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(
    job_index: nil,
    output:    LogCapture::String.new(content: ''),
    passed:    reporter.passed?,
    runtime:   timer.now - start
  )
end

#setupself

Setup integration

Returns:

  • (self)


93
94
95
96
97
98
99
100
101
102
# File 'lib/mutant/integration/minitest.rb', line 93

def setup
  Pathname.glob(TEST_FILE_PATTERN)
    .map(&:to_s)
    .reject { |path| path.include?('/vendor/') }
    .each(&world.kernel.public_method(:require))

  ::Minitest.seed ||= world.random.srand if ::Minitest.respond_to?(:seed=)

  self
end