Class: Mutineer::AggregateResult
- Inherits:
-
Object
- Object
- Mutineer::AggregateResult
- 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, uncapturable, skipped (invalid), errored, timeout, and ignored (#10 equivalent-mutant suppression) are each excluded and surfaced separately — so suppressing every survivor reaches 100%. An empty denominator yields a nil score (rendered "N/A"), never 0.0 — distinguishing "no testable mutants" from "0% killed".
Instance Attribute Summary collapse
-
#results ⇒ Object
readonly
Returns the value of attribute results.
Instance Method Summary collapse
-
#by_source ⇒ Hash<String, Mutineer::AggregateResult>
#11: split into { source_file => AggregateResult } so the Reporter (per-source breakdown) and #13 (per-source roll-up / baseline diff) can reuse the same aggregate math.
-
#covered_count ⇒ Integer
The score denominator (also shown to the reader).
-
#errored_count ⇒ Integer
Errored count.
-
#ignored_count ⇒ Integer
Ignored count.
-
#initialize(results) ⇒ AggregateResult
constructor
Builds an aggregate from results.
-
#killed_count ⇒ Integer
Killed count.
-
#mutation_score ⇒ Float?
Computes the mutation score.
-
#no_coverage_count ⇒ Integer
No-coverage count.
-
#skipped_invalid_count ⇒ Integer
Skipped-invalid count.
-
#survived_count ⇒ Integer
Survived count.
-
#surviving_mutants ⇒ Array<Mutineer::Result>
Returns the surviving mutants.
-
#timeout_count ⇒ Integer
Timeout count.
-
#total ⇒ Integer
Every generated, classified mutation.
-
#uncapturable_count ⇒ Integer
Uncapturable count.
Constructor Details
#initialize(results) ⇒ AggregateResult
Builds an aggregate from results.
108 109 110 111 |
# File 'lib/mutineer/result.rb', line 108 def initialize(results) @results = results @by_status = results.group_by(&:status) end |
Instance Attribute Details
#results ⇒ Object (readonly)
Returns the value of attribute results.
103 104 105 |
# File 'lib/mutineer/result.rb', line 103 def results @results end |
Instance Method Details
#by_source ⇒ Hash<String, Mutineer::AggregateResult>
#11: split into { source_file => AggregateResult } so the Reporter (per-source breakdown) and #13 (per-source roll-up / baseline diff) can reuse the same aggregate math.
159 160 161 162 163 |
# File 'lib/mutineer/result.rb', line 159 def by_source @results.select { |r| r.subject } .group_by { |r| r.subject.file } .transform_values { |rs| AggregateResult.new(rs) } end |
#covered_count ⇒ Integer
The score denominator (also shown to the reader).
138 |
# File 'lib/mutineer/result.rb', line 138 def covered_count = killed_count + survived_count |
#errored_count ⇒ Integer
Returns errored count.
124 125 |
# File 'lib/mutineer/result.rb', line 124 def errored_count = count(:error) # @return [Integer] timeout count. |
#ignored_count ⇒ Integer
Returns ignored count.
128 |
# File 'lib/mutineer/result.rb', line 128 def ignored_count = count(:ignored) |
#killed_count ⇒ Integer
Returns killed count.
114 115 |
# File 'lib/mutineer/result.rb', line 114 def killed_count = count(:killed) # @return [Integer] survived count. |
#mutation_score ⇒ Float?
Computes the mutation score.
143 144 145 146 147 |
# File 'lib/mutineer/result.rb', line 143 def mutation_score return nil if covered_count.zero? (killed_count.to_f / covered_count * 100).round(1) end |
#no_coverage_count ⇒ Integer
Returns no-coverage count.
118 119 |
# File 'lib/mutineer/result.rb', line 118 def no_coverage_count = count(:no_coverage) # @return [Integer] uncapturable count. |
#skipped_invalid_count ⇒ Integer
Returns skipped-invalid count.
122 123 |
# File 'lib/mutineer/result.rb', line 122 def skipped_invalid_count = count(:skipped) # @return [Integer] errored count. |
#survived_count ⇒ Integer
Returns survived count.
116 117 |
# File 'lib/mutineer/result.rb', line 116 def survived_count = count(:survived) # @return [Integer] no-coverage count. |
#surviving_mutants ⇒ Array<Mutineer::Result>
Returns the surviving mutants.
152 |
# File 'lib/mutineer/result.rb', line 152 def surviving_mutants = @results.select(&:survived?) |
#timeout_count ⇒ Integer
Returns timeout count.
126 127 |
# File 'lib/mutineer/result.rb', line 126 def timeout_count = count(:timeout) # @return [Integer] ignored count. |
#total ⇒ Integer
Every generated, classified mutation. NOT the score denominator.
133 |
# File 'lib/mutineer/result.rb', line 133 def total = @results.size |
#uncapturable_count ⇒ Integer
Returns uncapturable count.
120 121 |
# File 'lib/mutineer/result.rb', line 120 def uncapturable_count = count(:uncapturable) # @return [Integer] skipped-invalid count. |