Class: Mutant::Runner::Config

Inherits:
Mutant::Runner show all
Defined in:
lib/mutant/runner/config.rb

Overview

Runner for object config

Constant Summary collapse

COVERAGE_PRECISION =

The expected coverage precision

1

Constants inherited from Mutant::Runner

REGISTRY

Instance Attribute Summary collapse

Attributes inherited from Mutant::Runner

#config

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Mutant::Runner

#initialize, #running?, #runtime, #stop?

Constructor Details

This class inherits a constructor from Mutant::Runner

Instance Attribute Details

#subjectsEnumerable<Runner::Subject> (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return subject runners

Returns:



33
34
35
# File 'lib/mutant/runner/config.rb', line 33

def subjects
  @subjects
end

Class Method Details

.run(config) ⇒ Runner

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Run runner for object

Parameters:

  • config (Config)
  • object (Object)

Returns:



22
23
24
25
# File 'lib/mutant/runner/config.rb', line 22

def self.run(config)
  handler = lookup(config.class)
  handler.new(config)
end

Instance Method Details

#amount_killsFixnum

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return amount of kills

Returns:

  • (Fixnum)


89
90
91
# File 'lib/mutant/runner/config.rb', line 89

def amount_kills
  mutations.select(&:success?).length
end

#amount_mutationsFixnum

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return amount of mutations

Returns:

  • (Fixnum)


111
112
113
# File 'lib/mutant/runner/config.rb', line 111

def amount_mutations
  mutations.length
end

#coverageFloat

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return coverage

Returns:

  • (Float)


77
78
79
80
# File 'lib/mutant/runner/config.rb', line 77

def coverage
  return 0.0 if amount_mutations.zero? && amount_kills.zero?
  (amount_kills.to_f / amount_mutations) * 100
end

#failed_subjectsEnumerable<Subject>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return failed subjects

Returns:



41
42
43
# File 'lib/mutant/runner/config.rb', line 41

def failed_subjects
  subjects.reject(&:success?)
end

#mutationsArray<Mutation>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return mutations

Returns:



100
101
102
# File 'lib/mutant/runner/config.rb', line 100

def mutations
  subjects.map(&:mutations).flatten
end

#strategyStrategy

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return strategy

Returns:



67
68
69
# File 'lib/mutant/runner/config.rb', line 67

def strategy
  config.strategy
end

#success?true, false

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Test if run was successful

Returns:

  • (true)

    if run was successful

  • (false)

    otherwise



56
57
58
# File 'lib/mutant/runner/config.rb', line 56

def success?
  coverage.round(COVERAGE_PRECISION) == config.expected_coverage.round(COVERAGE_PRECISION)
end