Problem
An unnamed snapshot is named after the test function, and a @data_provider
runs that function once per value — so every value compares against the same
file:
function provide_values() { echo "alpha"; echo "beta"; }
# @data_provider provide_values
function test_shared() { assert_match_snapshot "value is $1"; }
The first value creates the snapshot; the second fails with
Expected to match the snapshot even though nothing about it is wrong. The
message is accurate about the symptom and silent about the cause.
What I changed, and what I did not
Documented the interaction in docs/assertions.md, pointing at
assert_match_named_snapshot "$1" for one file per value.
I tried putting the hint in the failure message and reverted it: the
renderer has no signal for "this test ran with provider arguments".
_BASHUNIT_CURRENT_TEST_INTERPOLATED_NAME looked like one but is only set for
::N::-style interpolated titles, so the hint never fired. Exposing such a
signal is a design change rather than a message fix, and it is the maintainer's
call.
Giving each value its own snapshot file would be the other fix, and a bigger
one: it would orphan every snapshot already on disk.
An acceptance test now pins the current behaviour either way.
Problem
An unnamed snapshot is named after the test function, and a
@data_providerruns that function once per value — so every value compares against the same
file:
The first value creates the snapshot; the second fails with
Expected to match the snapshoteven though nothing about it is wrong. Themessage is accurate about the symptom and silent about the cause.
What I changed, and what I did not
Documented the interaction in
docs/assertions.md, pointing atassert_match_named_snapshot "$1"for one file per value.I tried putting the hint in the failure message and reverted it: the
renderer has no signal for "this test ran with provider arguments".
_BASHUNIT_CURRENT_TEST_INTERPOLATED_NAMElooked like one but is only set for::N::-style interpolated titles, so the hint never fired. Exposing such asignal is a design change rather than a message fix, and it is the maintainer's
call.
Giving each value its own snapshot file would be the other fix, and a bigger
one: it would orphan every snapshot already on disk.
An acceptance test now pins the current behaviour either way.