Class: Mutineer::AggregateResult

Inherits:
Object
  • Object
show all
Defined in:
lib/mutineer/result.rb

Overview

Aggregates a flat list of Results into counts, the mutation score, and the surviving-mutant list. The score denominator is killed + survived ONLY (KTD-4): no-coverage, skipped (invalid), errored, and timeout are each excluded and surfaced separately. An empty denominator yields a nil score (rendered "N/A"), never 0.0 — distinguishing "no testable mutants" from "0% killed".

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(results) ⇒ AggregateResult

Returns a new instance of AggregateResult.



45
46
47
48
# File 'lib/mutineer/result.rb', line 45

def initialize(results)
  @results = results
  @by_status = results.group_by(&:status)
end

Instance Attribute Details

#resultsObject (readonly)

Returns the value of attribute results.



43
44
45
# File 'lib/mutineer/result.rb', line 43

def results
  @results
end

Instance Method Details

#covered_countObject

The score denominator (also shown to the reader).



61
# File 'lib/mutineer/result.rb', line 61

def covered_count = killed_count + survived_count

#errored_countObject



54
# File 'lib/mutineer/result.rb', line 54

def errored_count         = count(:error)

#killed_countObject



50
# File 'lib/mutineer/result.rb', line 50

def killed_count          = count(:killed)

#mutation_scoreObject

killed / (killed + survived) as a rounded percentage, or nil when nothing was testable.



65
66
67
68
69
# File 'lib/mutineer/result.rb', line 65

def mutation_score
  return nil if covered_count.zero?

  (killed_count.to_f / covered_count * 100).round(1)
end

#no_coverage_countObject



52
# File 'lib/mutineer/result.rb', line 52

def no_coverage_count     = count(:no_coverage)

#skipped_invalid_countObject



53
# File 'lib/mutineer/result.rb', line 53

def skipped_invalid_count = count(:skipped)

#survived_countObject



51
# File 'lib/mutineer/result.rb', line 51

def survived_count        = count(:survived)

#surviving_mutantsObject



71
# File 'lib/mutineer/result.rb', line 71

def surviving_mutants = @results.select(&:survived?)

#timeout_countObject



55
# File 'lib/mutineer/result.rb', line 55

def timeout_count         = count(:timeout)

#totalObject

Every generated, classified mutation. NOT the score denominator.



58
# File 'lib/mutineer/result.rb', line 58

def total = @results.size