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>)


108
109
110
# File 'lib/mutant/integration/minitest.rb', line 108

def all_tests
  all_tests_index.keys
end

#call(tests) ⇒ Result::Test

Call test integration

rubocop:disable MethodLength

ignore :reek:TooManyStatements

Parameters:

  • tests (Array<Tests>)

Returns:

  • (Result::Test)


82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/mutant/integration/minitest.rb', line 82

def call(tests)
  test_cases = tests.map(&all_tests_index.method(:fetch))
  output     = StringIO.new
  start      = Timer.now

  reporter = ::Minitest::SummaryReporter.new(output)

  reporter.start

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

  output.rewind

  Result::Test.new(
    passed:  reporter.passed?,
    tests:   tests,
    output:  output.read,
    runtime: Timer.now - start
  )
end

#setupself

Setup integration

Returns:

  • (self)


65
66
67
68
69
70
71
# File 'lib/mutant/integration/minitest.rb', line 65

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

  self
end