Mutare (mutare v0.1.2)

Copy Markdown View Source

Mutare is a mutation testing system for Elixir, that mutates the source you actually write, and compiles once.

The whole project is downstream of one invariant: compile once. Mutare rewrites a project's source into a metamutant — a single program that embeds every mutant behind a :persistent_term runtime switch — compiles it once, then runs the suite once per mutant by flipping MUTARE_ACTIVE_MUTANT.

On top of that, the runner adds coverage-guided test selection, compile-poison recovery, parallel execution, timeouts, ignore annotations, and changed-file scoping via --since.

Most users drive Mutare through the mix mutare task; run/2 is the programmatic entry point and transform_string/2 exposes the source rewrite on its own. See Mutare.Runner for the run flow and Mutare.Mutator for writing your own mutators.

Summary

Functions

Run mutation testing against the project at root, returning {:ok, %Mutare.Run{}} on success. See Mutare.Runner.run/2.

Transform a source string into a metamutant and public mutant descriptions.

Functions

run(root \\ ".", opts \\ [])

Run mutation testing against the project at root, returning {:ok, %Mutare.Run{}} on success. See Mutare.Runner.run/2.

transform_string(source, opts \\ [])

Transform a source string into a metamutant and public mutant descriptions.

iex> source = "defmodule Calculator do\n  def add(a, b), do: a + b\nend\n"
iex> result = Mutare.transform_string(source, mutators: [:arithmetic])
iex> [site] = result.mutants
iex> {site.id, site.mutator, site.original_code, site.mutated_code, result.next_id}
{1, :arithmetic, "a + b", "a - b", 2}