free_mutant/lib/mutant/reporter/cli/printer/isolation_result.rb
Markus Schirp 31bc77ee12 Change isolation interface to separate isolation errors
* Before, when code inside the isolation failed outside the tests we
  counted this as a mutation kill.
* Now we report them explicitly as not killed mutations. As they where
  not killed by the tests.
2018-12-04 14:26:23 +00:00

62 lines
1.5 KiB
Ruby

# frozen_string_literal: true
module Mutant
class Reporter
class CLI
class Printer
# Reporter for mutation results
#
# :reek:TooManyConstants
class IsolationResult < self
ERROR_MESSAGE = <<~'MESSAGE'
Killing the mutation resulted in an integration error.
This is the case when the tests selected for the current mutation
did not produce a test result, but instead an exception was raised.
This may point to the following problems:
* Bug in mutant
* Bug in the ruby interpreter
* Bug in your test suite
* Bug in your test suite under concurrency
The following exception was raised:
```
%s
%s
```
MESSAGE
private_constant(*constants(false))
# Run report printer
#
# @return [undefined]
def run
if object.success?
visit(TestResult, object.value)
else
visit_error_result
end
end
private
# Visit failed test results
#
# @return [undefined]
def visit_error_result
exception = object.error
puts(
ERROR_MESSAGE % [
exception.inspect,
exception.backtrace.join("\n")
]
)
end
end # IsolationResult
end # Printer
end # CLI
end # Reporter
end # Mutant