harnais_runner v0.1.0 Harnais.Runner.Correr View Source
The correr manages a complete test run with one or more tests (provas).
Each test runner create a correr to manage the run.
See Harnais.Runner
for the overview.
Correr State
A correr has the following fields:
Key | Aliases |
---|---|
:test_type | :type |
:test_runner | :runner |
:test_specs | :t, :tests, :specs, :test_specifications |
:test_value | :v, :value |
:test_module | :d, :module |
:test_namer | :n, :namer |
:test_mapper | :m, :mapper |
:test_transform | :p, :transform |
:test_provas |
The default for all fields is the unset value (Plymio.Fontais.Guard.the_unset_value/0
).
Correr Field: :test_type
The type of the run (e.g. reduce
) derived from the test runner name (e.g. run_tests_reduce_test_value/1
)
Correr Field: :test_runner
The default function to run each test. Each :test_type
(e.g. reduce
) has its own default but can be overridden.
Correr Field: :test_specs
The :test_specs
passed to the test_runner.
Correr Field: :test_value
The default value passed as the first argument to the :test_call
(see the prova).
Correr Field: :test_module
The name of the default module to use in the :test_call
(see the prova).
Correr Field: :test_namer
The default test namer passed to each prova.
Correr Field: :test_mapper
See the explanation here.
Correr Field: :test_transform
See the explanation here.
Correr Field: :test_provas
Each specification in the :test_specs
is used to create a
prova. The :test_provas
holds the list
of provas.
Link to this section Summary
Link to this section Types
Link to this section Functions
new/1
creates a new instance of the module’s struct
and, if the optional
opts were given, calls update/2
with the instance and the opts,
returning {:ok, instance}
, else {:error, error}
.
run/1
takes a correr and runs each prova.
Examples
Tests for a correr look very similar to test runner ones e.g. same.
iex> {:ok, {answer, %CORRER{}}} = [
...> type: :same, runner: &Harnais.Runner.run_tests_same_test_runner/2,
...> module: Map, value: %{a: 42},
...> test_specs: [[args: [:a], call: [:get], result: 42]],
...> ] |> CORRER.new! |> CORRER.run
...> answer
42
update/2
takes an instance
of the module’s struct
and an optional opts.
The opts are normalised by calling the module’s update_canonical_opts/1
and then reduced with update_field/2
:
opts |> Enum.reduce(instance, fn {k,v}, s -> s |> update_field({k,v}) end)
{:ok, instance}
is returned.