ExUnitJSON.Config (ex_unit_json v0.4.2)

Copy Markdown View Source

Centralized configuration handling for ExUnitJSON.

Provides option parsing, validation, and retrieval. Options are stored in Application environment during test runs (single-instance, so this is acceptable).

Options

  • :summary_only - When true, omit individual test results
  • :failures_only - When true, include only failed tests
  • :first_failure - When true, include only the first failed test
  • :filter_out - List of patterns to mark matching failures as filtered
  • :output - File path to write JSON output (default: stdout)
  • :compact - When true, output JSONL with minimal fields
  • :group_by_error - When true, add error_groups array grouping failures by message

Summary

Types

Valid option keys for ExUnitJSON configuration

Keyword list of ExUnitJSON options

Functions

Checks if compact mode is enabled.

Checks if failures-only mode is enabled.

Gets the list of filter-out patterns.

Checks if first-failure mode is enabled.

Gets a specific option value.

Gets options from Application environment.

Checks if group-by-error mode is enabled.

Gets the output file path, or nil for stdout.

Checks if summary-only mode is enabled.

Types

option()

@type option() ::
  :summary_only
  | :failures_only
  | :first_failure
  | :filter_out
  | :output
  | :compact
  | :group_by_error

Valid option keys for ExUnitJSON configuration

opts()

@type opts() :: [
  summary_only: boolean(),
  failures_only: boolean(),
  first_failure: boolean(),
  filter_out: [String.t()],
  output: String.t() | nil,
  compact: boolean(),
  group_by_error: boolean()
]

Keyword list of ExUnitJSON options

Functions

compact?()

@spec compact?() :: boolean()

Checks if compact mode is enabled.

failures_only?()

@spec failures_only?() :: boolean()

Checks if failures-only mode is enabled.

Returns true by default (AI-optimized output). Use --all flag to get all tests.

filter_out_patterns()

@spec filter_out_patterns() :: [String.t()]

Gets the list of filter-out patterns.

first_failure?()

@spec first_failure?() :: boolean()

Checks if first-failure mode is enabled.

get_opt(key, default \\ nil)

@spec get_opt(option(), any()) :: any()

Gets a specific option value.

Examples

Application.put_env(:ex_unit_json, :opts, summary_only: true)
ExUnitJSON.Config.get_opt(:summary_only)
#=> true

Application.put_env(:ex_unit_json, :opts, [])
ExUnitJSON.Config.get_opt(:summary_only, false)
#=> false

get_opts()

@spec get_opts() :: opts()

Gets options from Application environment.

Returns validated options, filtering out any invalid keys.

Examples

Application.put_env(:ex_unit_json, :opts, summary_only: true)
ExUnitJSON.Config.get_opts()
#=> [summary_only: true]

Application.put_env(:ex_unit_json, :opts, invalid_key: "ignored")
ExUnitJSON.Config.get_opts()
#=> []

group_by_error?()

@spec group_by_error?() :: boolean()

Checks if group-by-error mode is enabled.

output_path()

@spec output_path() :: String.t() | nil

Gets the output file path, or nil for stdout.

summary_only?()

@spec summary_only?() :: boolean()

Checks if summary-only mode is enabled.