-
-
Notifications
You must be signed in to change notification settings - Fork 41
Labels
bugSomething isn't workingSomething isn't working
Description
| Q | A |
|---|---|
| OS | macOS and Linux |
| Shell & version | bash 5.3.3 (macOS) and bash 5.2.32 (Linux) |
| bashunit version | 0.24.0 (both) |
Summary
When a custom assertion that uses the bashunit::assertion_failure helper fails during a test, the name reported in the test output is that of the function implementing the assertion logic, rather than that of the function defining the test. This is inconsistent with the built-in assertions, but may be intentional and by design.
How to reproduce
This test fails on purpose to demonstrate the inconsistent output:
function assert_foo() {
local actual="$1"
if [[ "foo" != "$actual" ]]; then
bashunit::assertion_failed "foo" "$actual"
return
fi
bashunit::assertion_passed
}
function test_custom_assert_output() {
assert_same 'foo' 'asdf'
assert_foo 'asdf'
}Output:
bashunit - 0.24.0 | Tests: 1
Running custom_test.sh
✗ Failed: Custom assert output
Expected 'foo'
but got 'asdf'
✗ Failed: Assert foo
Expected 'foo'
but got 'asdf'
There was 1 failure:
|1) custom_test.sh:12
|✗ Failed: Custom assert output
| Expected 'foo'
| but got 'asdf'
|✗ Failed: Assert foo
| Expected 'foo'
| but got 'asdf'
Tests: 1 failed, 1 total
Assertions: 2 failed, 2 total
Some tests failed
Time taken: 154 ms
Expected behavior
Assuming that the demonstrated behavior isn't intentional and by design, Failed: Assert Foo should be expected to read Failed: Custom assert output to be consistent with bashunit's built-in assertions.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
Type
Projects
Status
Done