Add specification for runner isolation errors
This commit is contained in:
parent
c986cedd84
commit
d5f5564dc0
2 changed files with 64 additions and 32 deletions
|
@ -121,13 +121,16 @@ module Mutant
|
|||
# @api private
|
||||
#
|
||||
def run_mutation_test(mutation, test)
|
||||
time = Time.now
|
||||
config.isolation.call do
|
||||
mutation.insert
|
||||
test.run
|
||||
end.update(test: test, mutation: mutation)
|
||||
rescue Isolation::Error
|
||||
rescue Isolation::Error => exception
|
||||
Result::Test.new(
|
||||
test: test,
|
||||
mutation: mutation,
|
||||
runtime: Time.now - time,
|
||||
output: exception.message,
|
||||
passed: false
|
||||
)
|
||||
|
|
|
@ -4,7 +4,7 @@ describe Mutant::Runner do
|
|||
let(:object) { described_class.new(env) }
|
||||
|
||||
let(:reporter) { Mutant::Reporter::Trace.new }
|
||||
let(:config) { Mutant::Config::DEFAULT.update(reporter: reporter) }
|
||||
let(:config) { Mutant::Config::DEFAULT.update(reporter: reporter, isolation: Mutant::Isolation::None) }
|
||||
let(:subjects) { [subject_a, subject_b] }
|
||||
|
||||
class Double
|
||||
|
@ -63,12 +63,6 @@ describe Mutant::Runner do
|
|||
allow(Time).to receive(:now).and_return(time)
|
||||
end
|
||||
|
||||
describe '#result' do
|
||||
subject { object.result }
|
||||
|
||||
its(:env) { should be(env) }
|
||||
its(:subject_results) { should eql(expected_subject_results) }
|
||||
|
||||
let(:expected_subject_results) do
|
||||
[
|
||||
Mutant::Result::Subject.new(
|
||||
|
@ -94,5 +88,40 @@ describe Mutant::Runner do
|
|||
)
|
||||
]
|
||||
end
|
||||
|
||||
describe '#result' do
|
||||
context 'on normal execution' do
|
||||
subject { object.result }
|
||||
|
||||
its(:env) { should be(env) }
|
||||
its(:subject_results) { should eql(expected_subject_results) }
|
||||
end
|
||||
|
||||
context 'when isolation raises error' do
|
||||
subject { object.result }
|
||||
|
||||
its(:env) { should be(env) }
|
||||
its(:subject_results) { should eql(expected_subject_results) }
|
||||
|
||||
before do
|
||||
expect(Mutant::Isolation::None).to receive(:call).and_raise(Mutant::Isolation::Error.new('test-exception-message')).twice
|
||||
|
||||
expect(Mutant::Result::Test).to receive(:new).with(
|
||||
test: test_a1,
|
||||
mutation: mutation_a1,
|
||||
runtime: 0.0,
|
||||
output: 'test-exception-message',
|
||||
passed: false
|
||||
).and_return(test_report_a1)
|
||||
expect(Mutant::Result::Test).to receive(:new).with(
|
||||
test: test_a1,
|
||||
mutation: mutation_a2,
|
||||
runtime: 0.0,
|
||||
output: 'test-exception-message',
|
||||
passed: false
|
||||
).and_return(test_report_a1)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue