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, 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

Instance Method Summary collapse

Constructor Details

#initialize(results) ⇒ AggregateResult

Builds an aggregate from results.

Parameters:



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

#resultsObject (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_sourceHash<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.

Returns:



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_countInteger

The score denominator (also shown to the reader).

Returns:

  • (Integer)

    killed plus survived.



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

def covered_count = killed_count + survived_count

#errored_countInteger

Returns errored count.

Returns:

  • (Integer)

    errored count.



124
125
# File 'lib/mutineer/result.rb', line 124

def errored_count         = count(:error)
# @return [Integer] timeout count.

#ignored_countInteger

Returns ignored count.

Returns:

  • (Integer)

    ignored count.



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

def ignored_count         = count(:ignored)

#killed_countInteger

Returns killed count.

Returns:

  • (Integer)

    killed count.



114
115
# File 'lib/mutineer/result.rb', line 114

def killed_count          = count(:killed)
# @return [Integer] survived count.

#mutation_scoreFloat?

Computes the mutation score.

Returns:

  • (Float, nil)

    score percentage or nil when nothing was testable.



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_countInteger

Returns no-coverage count.

Returns:

  • (Integer)

    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_countInteger

Returns skipped-invalid count.

Returns:

  • (Integer)

    skipped-invalid count.



122
123
# File 'lib/mutineer/result.rb', line 122

def skipped_invalid_count = count(:skipped)
# @return [Integer] errored count.

#survived_countInteger

Returns survived count.

Returns:

  • (Integer)

    survived count.



116
117
# File 'lib/mutineer/result.rb', line 116

def survived_count        = count(:survived)
# @return [Integer] no-coverage count.

#surviving_mutantsArray<Mutineer::Result>

Returns the surviving mutants.

Returns:



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

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

#timeout_countInteger

Returns timeout count.

Returns:

  • (Integer)

    timeout count.



126
127
# File 'lib/mutineer/result.rb', line 126

def timeout_count         = count(:timeout)
# @return [Integer] ignored count.

#totalInteger

Every generated, classified mutation. NOT the score denominator.

Returns:

  • (Integer)

    total result count.



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

def total = @results.size

#uncapturable_countInteger

Returns uncapturable count.

Returns:

  • (Integer)

    uncapturable count.



120
121
# File 'lib/mutineer/result.rb', line 120

def uncapturable_count    = count(:uncapturable)
# @return [Integer] skipped-invalid count.