View Source ExUnitAtlas (ex_unit_atlas v0.2.0)
Adds named behavior steps, checks, and data previews to regular ExUnit tests.
Use this module after use ExUnit.Case (or a project-specific case
template):
defmodule Shop.SaleTest do
use ExUnit.Case, async: true
use ExUnitAtlas
test "cash sales are fiscalized" do
sale =
step "Create a cash sale" do
%{payment_type: :cash}
end
|> show("Created sale")
check "The sale is eligible for fiscalization" do
assert sale.payment_type == :cash
end
end
endstep/2, check/2, and show/2 preserve the values flowing through the
test. Add ExUnitAtlas.Formatter alongside the standard ExUnit CLI formatter
to generate the report.
Summary
Functions
Runs and records a named human-readable assertion block.
Records a bounded preview of value and returns the original value.
Runs and records a named scenario step.
Functions
Runs and records a named human-readable assertion block.
A check can contain one or more regular ExUnit assertions. Atlas does not inspect or replace them, and preserves their normal failures. The name must be a non-empty string. Nested items are not supported.
Records a bounded preview of value and returns the original value.
show/2 is pipe-friendly:
sale
|> show("Sale after creation")
|> persist_sale()The preview uses inspect/2 with bounded collection and string limits, then
truncates the final representation to 2,000 characters. Atlas records only
that string representation, never the original term.
Values may contain credentials, personal data, or other secrets. Use
show/2 only for data that is safe to store in local and CI report
artifacts.
The label must be a non-empty string. show/2 cannot be called from inside
an open step or check; place it after the block, typically through a
pipeline.
Runs and records a named scenario step.
The block is executed exactly once and its value is returned unchanged. Errors, exits and throws are re-raised with their original reason and stacktrace. The name must be a non-empty string. Nested items are not supported.