Mutare.Report.Json (mutare v0.5.0)

Copy Markdown View Source

Renders a mutation run as a mutation-testing-elements report-schema JSON document (the schema used by Stryker and its viewer/dashboard).

This is the lossless machine format: every mutant (not just survivors) is emitted, keyed by file, with its location and status. A mutant the run has no result for — a report written before the run finished, or after it stopped early — is emitted as Pending, so a partial report never reads as a complete one. Mutare's Mutare.Result statuses map exactly onto the schema's MutantStatus vocabulary (see status/1), so the report drops straight into the existing ecosystem — Mutare.Report.Html embeds this same document into the report web component, and it can be uploaded to the Stryker dashboard unchanged.

Two fields locate a mutant. The schema's location is the source span its replacement text replaces. Mutare adds position, a {line, column} point: where the mutant is, the location the human report prints and --line selects by. Its line is the one # mutare:ignore reads. Usually position is where location starts. A mutant whose replacement must cover more text than it changes is the exception: removing a pipe stage, for instance, rewrites the whole pipe but is positioned at the stage.

Emitted by mix mutare --report json or mix mutare --report json:path.json.

Summary

Functions

Render results and their original sources as a report-schema JSON string.

Functions

render(results, sources, opts \\ [])

@spec render([Mutare.Result.t()], %{optional(String.t()) => String.t()}, keyword()) ::
  String.t()

Render results and their original sources as a report-schema JSON string.

opts[:min_score] (when set) becomes the report's score thresholds, and opts[:pending] lists the sites with no result yet, emitted as Pending.