ExUnit v1.2.6 ExUnit.Formatter

This module holds helper functions related to formatting and contains documentation about the formatting protocol.

Formatters are registered at the ExUnit.EventManager event manager and will be send events by the runner.

The following events are possible:

  • {:suite_started, opts} - the suite has started with the specified options to the runner.

  • {:suite_finished, run_us, load_us} - the suite has finished. run_us and load_us are the run and load times in microseconds respectively.

  • {:case_started, test_case} - a test case has started. See ExUnit.TestCase for details.

  • {:case_finished, test_case} - a test case has finished. See ExUnit.TestCase for details.

  • {:test_started, test_case} - a test case has started. See ExUnit.Test for details.

  • {:test_finished, test_case} - a test case has finished. See ExUnit.Test for details.

Summary

Functions

Formats filters used to constrain cases to be run

Receives a test and formats its failure

Formats time taken running the test suite

Types

id()
id() :: term
load_us()
load_us() :: pos_integer | nil
run_us()
run_us() :: pos_integer
test()
test() :: ExUnit.Test.t
test_case()
test_case() :: ExUnit.TestCase.t

Functions

format_filters(filters, type)
format_filters(Keyword.t, atom) :: String.t

Formats filters used to constrain cases to be run.

Examples

iex> format_filters([run: true, slow: false], :include)
"Including tags: [run: true, slow: false]"
format_test_case_failure(test_case, failures, counter, width, formatter)

Receives a test case and formats its failure.

format_test_failure(test, failures, counter, width, formatter)

Receives a test and formats its failure.

format_time(run_us, load_us)
format_time(run_us, load_us) :: String.t

Formats time taken running the test suite.

It receives the time spent running the tests and optionally the time spent loading the test suite.

Examples

iex> format_time(10000, nil)
"Finished in 0.01 seconds"

iex> format_time(10000, 20000)
"Finished in 0.03 seconds (0.02s on load, 0.01s on tests)"

iex> format_time(10000, 200000)
"Finished in 0.2 seconds (0.2s on load, 0.01s on tests)"