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> Also known as: available_tests

All tests exposed by this integration

Returns:

  • (Array<Test>)


122
123
124
# File 'lib/mutant/integration/minitest.rb', line 122

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)


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

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:    '',
    passed:    reporter.passed?,
    runtime:   timer.now - start
  )
end

#setupself

Setup integration

Returns:

  • (self)


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

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

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

  self
end