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 ⇒ Object
#11: split into { source_file => AggregateResult } so the Reporter (per-source breakdown) and #13 (per-source roll-up / baseline diff) share one shape with all the score/count methods.
-
#covered_count ⇒ Object
The score denominator (also shown to the reader).
- #errored_count ⇒ Object
- #ignored_count ⇒ Object
-
#initialize(results) ⇒ AggregateResult
constructor
A new instance of AggregateResult.
- #killed_count ⇒ Object
-
#mutation_score ⇒ Object
killed / (killed + survived) as a rounded percentage, or nil when nothing was testable.
- #no_coverage_count ⇒ Object
- #skipped_invalid_count ⇒ Object
- #survived_count ⇒ Object
- #surviving_mutants ⇒ Object
- #timeout_count ⇒ Object
-
#total ⇒ Object
Every generated, classified mutation.
- #uncapturable_count ⇒ Object
Constructor Details
#initialize(results) ⇒ AggregateResult
Returns a new instance of AggregateResult.
60 61 62 63 |
# File 'lib/mutineer/result.rb', line 60 def initialize(results) @results = results @by_status = results.group_by(&:status) end |
Instance Attribute Details
#results ⇒ Object (readonly)
Returns the value of attribute results.
58 59 60 |
# File 'lib/mutineer/result.rb', line 58 def results @results end |
Instance Method Details
#by_source ⇒ Object
#11: split into { source_file => AggregateResult } so the Reporter (per-source breakdown) and #13 (per-source roll-up / baseline diff) share one shape with all the score/count methods. After Runner.execute every result carries a subject, so the grouping is total; bare results (no subject, only in unit tests) are skipped so file keys stay sortable strings.
95 96 97 98 99 |
# File 'lib/mutineer/result.rb', line 95 def by_source @results.select { |r| r.subject } .group_by { |r| r.subject.file } .transform_values { |rs| AggregateResult.new(rs) } end |
#covered_count ⇒ Object
The score denominator (also shown to the reader).
78 |
# File 'lib/mutineer/result.rb', line 78 def covered_count = killed_count + survived_count |
#errored_count ⇒ Object
70 |
# File 'lib/mutineer/result.rb', line 70 def errored_count = count(:error) |
#ignored_count ⇒ Object
72 |
# File 'lib/mutineer/result.rb', line 72 def ignored_count = count(:ignored) |
#killed_count ⇒ Object
65 |
# File 'lib/mutineer/result.rb', line 65 def killed_count = count(:killed) |
#mutation_score ⇒ Object
killed / (killed + survived) as a rounded percentage, or nil when nothing was testable.
82 83 84 85 86 |
# File 'lib/mutineer/result.rb', line 82 def mutation_score return nil if covered_count.zero? (killed_count.to_f / covered_count * 100).round(1) end |
#no_coverage_count ⇒ Object
67 |
# File 'lib/mutineer/result.rb', line 67 def no_coverage_count = count(:no_coverage) |
#skipped_invalid_count ⇒ Object
69 |
# File 'lib/mutineer/result.rb', line 69 def skipped_invalid_count = count(:skipped) |
#survived_count ⇒ Object
66 |
# File 'lib/mutineer/result.rb', line 66 def survived_count = count(:survived) |
#surviving_mutants ⇒ Object
88 |
# File 'lib/mutineer/result.rb', line 88 def surviving_mutants = @results.select(&:survived?) |
#timeout_count ⇒ Object
71 |
# File 'lib/mutineer/result.rb', line 71 def timeout_count = count(:timeout) |
#total ⇒ Object
Every generated, classified mutation. NOT the score denominator.
75 |
# File 'lib/mutineer/result.rb', line 75 def total = @results.size |
#uncapturable_count ⇒ Object
68 |
# File 'lib/mutineer/result.rb', line 68 def uncapturable_count = count(:uncapturable) |