Juggernaut.Advise (Juggernaut v0.4.0)

Copy Markdown View Source

What mix juggernaut.advise says about a recorded run (design notes §3, §10.8), from data Juggernaut already keeps: the run's results (each mutant's selection), the coverage index (who hit each site, Juggernaut.Coverage.Index), the warm/fresh pairs of its boot set (Juggernaut.WarmSafe.pairs/2) and the tags the test files carry.

Mutants, by how their tests were chosen:

  • :unit - tests that hit the site in their own processes (tests, reconfirm);
  • :startup - the site runs while the app starts or the tests load (boot, or warm_first when a warm-safe declaration settled it): each needs a fresh boot;
  • :integration - the site runs outside any single test (suite: a cast, a timer, a message, a process no test owns; file: setup_all, on_exit): whole files or the whole suite run for it;
  • :uncovered - no test reaches it; :unscored - ignored, equivalent, not compiled.

Test files, by what the probe saw them do: :integration when some of their hits ran in processes no test owns, :startup when they hit sites of the boot set, :unit otherwise. A file is declared an integration test as the test lanes say (test_lanes in .juggernaut.exs): it carries one of the integration tags (@moduletag, @describetag, @tag, or a case template it uses), or its path matches one of the integration paths. A file whose behaviour and declaration differ is listed as misclassified. integration_only counts the kills that only an integration test made (their unit tests all passed with the mutant on).

Each boot-set function gets one piece of advice: :declared (a warm-safe declaration applies), :unsafe (a warm result and a fresh one disagreed: keep booting it fresh), :declare (every pair agreed: a person may declare it warm-safe), :verify (no pair at the current code: run --verify) or :boot_only (no test runs it after boot, so it can never be settled warm). Seams are suggested for the startup-only and unsafe functions and for the code reached outside any test.

Summary

Functions

The advice on a boot-set function: from its declaration's state (nil for none), its evidence (Juggernaut.WarmSafe.evidence/5) and whether tests run it after boot.

The advice on run. Options

The categories, in report order.

A mutant's category from its result (see the module doc).

The lane a test file is declared in: :integration when it carries one of the integration tags or its path matches one of the paths globs, else :unit.

Why a test file declared declared that behaves as observed (hitting sites sites) is misclassified, or nil when it is not.

The seam suggested for a boot-set function given its advice (:boot_only or :unsafe) and whether it is a process start (init, start_link, ...).

Types

advice()

@type advice() :: :declared | :unsafe | :declare | :verify | :boot_only

category()

@type category() :: :unit | :startup | :integration | :uncovered | :unscored

t()

@type t() :: %{
  run_id: String.t(),
  lane: Juggernaut.Run.lane(),
  counts: %{required(category()) => non_neg_integer()},
  modules: [map()],
  startup: [map()],
  tests: [map()],
  misclassified: [map()],
  seams: [map()],
  declarations: [map()],
  integration_only: non_neg_integer(),
  integration: %{tags: [String.t()], paths: [String.t()]}
}

Functions

advice(arg1, arg2, arg3)

@spec advice(Juggernaut.WarmSafe.state() | nil, map(), boolean()) :: advice()

The advice on a boot-set function: from its declaration's state (nil for none), its evidence (Juggernaut.WarmSafe.evidence/5) and whether tests run it after boot.

analyse(run, opts)

@spec analyse(Juggernaut.Run.t(), keyword()) :: t()

The advice on run. Options:

  • :index - the coverage index (nil when there is none: no test rows, no seams that need labels);
  • :tags - each test file's tags (Juggernaut.Advise.Tags.of_files/3);
  • :integration - what declares an integration test: %{tags:, paths:} (strings, path globs; none by default);
  • :declarations - the warm-safe declarations (Juggernaut.WarmSafe);
  • :pairs - the warm/fresh pairs known (the run's and --verify's);
  • :hashes - each mutated file's function hashes now (Juggernaut.Cache.Footprint.file/1; a file missing is code that is gone).

categories()

@spec categories() :: [category()]

The categories, in report order.

category(result)

@spec category(Juggernaut.Result.t() | nil) :: category()

A mutant's category from its result (see the module doc).

declared(file, tags, integration)

@spec declared(String.t(), [atom()], %{tags: [String.t()], paths: [String.t()]}) ::
  :unit | :integration

The lane a test file is declared in: :integration when it carries one of the integration tags or its path matches one of the paths globs, else :unit.

misclassified(arg1, arg2, sites)

@spec misclassified(:unit | :integration, category(), non_neg_integer()) ::
  String.t() | nil

Why a test file declared declared that behaves as observed (hitting sites sites) is misclassified, or nil when it is not.

startup_suggestion(atom, arg2)

@spec startup_suggestion(:boot_only | :unsafe, boolean()) :: String.t()

The seam suggested for a boot-set function given its advice (:boot_only or :unsafe) and whether it is a process start (init, start_link, ...).