PropertyDamage.Mutation.Report (PropertyDamage v0.2.0)

View Source

Report structure for mutation testing results.

The report aggregates results from running mutations and provides statistics about test effectiveness.

Fields

  • mutation_score - Ratio of killed to total mutations (0.0 to 1.0)
  • killed - Number of mutations that were caught by tests
  • survived - Number of mutations that tests failed to catch
  • timeout - Number of mutations that timed out
  • total - Total number of mutations tested
  • by_command - Breakdown by command type
  • by_operator - Breakdown by mutation operator
  • survived_mutations - Details of mutations that survived
  • killed_mutations - Details of mutations that were killed
  • duration_ms - Total time taken
  • started_at - When testing started
  • completed_at - When testing completed

Summary

Functions

Finalizes the report with timing information.

Creates a new empty report.

Checks if the report passes the target score.

Records a mutation result in the report.

Returns commands sorted by kill rate (weakest first).

Returns operators sorted by kill rate (weakest first).

Types

command_stats()

@type command_stats() :: %{
  killed: non_neg_integer(),
  survived: non_neg_integer(),
  timeout: non_neg_integer(),
  total: non_neg_integer(),
  score: float()
}

mutation_result()

@type mutation_result() :: %{
  mutation: map(),
  command: module(),
  operator: atom(),
  result: :killed | :survived | :timeout,
  failure_message: String.t() | nil,
  duration_ms: non_neg_integer()
}

t()

@type t() :: %PropertyDamage.Mutation.Report{
  adapter: module() | nil,
  by_command: %{required(module()) => command_stats()},
  by_operator: %{required(atom()) => command_stats()},
  completed_at: DateTime.t() | nil,
  duration_ms: non_neg_integer(),
  killed: non_neg_integer(),
  killed_mutations: [mutation_result()],
  model: module() | nil,
  mutation_score: float(),
  started_at: DateTime.t() | nil,
  survived: non_neg_integer(),
  survived_mutations: [mutation_result()],
  target_score: float(),
  timeout: non_neg_integer(),
  total: non_neg_integer()
}

Functions

finalize(report, started_at, completed_at)

@spec finalize(t(), DateTime.t(), DateTime.t()) :: t()

Finalizes the report with timing information.

new(opts \\ [])

@spec new(keyword()) :: t()

Creates a new empty report.

passes?(report)

@spec passes?(t()) :: boolean()

Checks if the report passes the target score.

record_result(report, result)

@spec record_result(t(), mutation_result()) :: t()

Records a mutation result in the report.

weakest_commands(report)

@spec weakest_commands(t()) :: [{module(), command_stats()}]

Returns commands sorted by kill rate (weakest first).

weakest_operators(report)

@spec weakest_operators(t()) :: [{atom(), command_stats()}]

Returns operators sorted by kill rate (weakest first).