2013-07-28 19:03:06 -04:00
|
|
|
# encoding: utf-8
|
|
|
|
|
2012-08-01 13:05:34 -04:00
|
|
|
module Mutant
|
2014-04-28 15:17:25 -04:00
|
|
|
# Mutation killer
|
2012-08-14 06:27:56 -04:00
|
|
|
class Killer
|
2014-04-28 15:17:25 -04:00
|
|
|
include Adamantium::Flat
|
|
|
|
include Anima.new(:test, :mutation)
|
2013-02-01 17:39:00 -05:00
|
|
|
|
2014-04-28 15:17:25 -04:00
|
|
|
# Report object for kill results
|
|
|
|
class Report
|
|
|
|
include Anima.new(
|
|
|
|
:killer,
|
|
|
|
:test_report
|
|
|
|
)
|
2013-02-01 17:39:00 -05:00
|
|
|
|
2014-04-28 15:17:25 -04:00
|
|
|
# Test if kill was successful
|
|
|
|
#
|
|
|
|
# @return [Boolean]
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
|
|
|
def success?
|
|
|
|
killer.mutation.should_fail?.equal?(test_report.failed?)
|
|
|
|
end
|
2013-02-01 17:39:00 -05:00
|
|
|
|
2014-04-28 15:17:25 -04:00
|
|
|
end # Report
|
2013-04-17 23:31:21 -04:00
|
|
|
|
2014-04-28 15:17:25 -04:00
|
|
|
# Return test report
|
2012-08-01 13:05:34 -04:00
|
|
|
#
|
2014-05-09 19:15:25 -04:00
|
|
|
# @return [Test::Report]
|
2012-08-01 13:05:34 -04:00
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
2014-04-28 15:17:25 -04:00
|
|
|
def run
|
2014-05-09 19:15:25 -04:00
|
|
|
test_report = Mutant.isolate do
|
|
|
|
mutation.insert
|
|
|
|
test.run
|
|
|
|
end
|
|
|
|
|
2014-04-28 15:17:25 -04:00
|
|
|
Report.new(
|
2014-05-09 19:15:25 -04:00
|
|
|
killer: self,
|
|
|
|
test_report: test_report.update(test: test)
|
2014-04-28 15:17:25 -04:00
|
|
|
)
|
2013-01-15 17:46:05 -05:00
|
|
|
end
|
|
|
|
|
2012-12-07 11:14:18 -05:00
|
|
|
private
|
|
|
|
|
2013-08-04 12:49:42 -04:00
|
|
|
# Return subject
|
|
|
|
#
|
|
|
|
# @return [Subject]
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
|
|
|
def subject
|
|
|
|
mutation.subject
|
|
|
|
end
|
|
|
|
|
2013-06-14 14:54:02 -04:00
|
|
|
end # Killer
|
|
|
|
end # Mutant
|