bashunit
bashunit copied to clipboard
Add third optional parameter on asserts
This is already for assertEquals. Or on which functions do you mean?
@Chemaclass In fact, this functionality was implemented at the beginning but the other way around. What it did was allow you to customize the success message of the assert and not the failure one. When we changed so that success messages were for the tests and not for the asserts, it was lost.
I also wanted this, and went to look at what it would take to implement it.
Isn't it mostly done? Nearly all the assert_* functions use constructs like
function assert_equals() {
...
local label="${3:-$(helper::normalize_test_function_name "${FUNCNAME[1]}")}"
...
console_results::print_failed_test "${label}" "${expected}" "but got" "${actual}"
so, for example, passing a third argument to assert_equals prints that when the assertion fails.
As far as I can tell, only the array and snapshot assertions are missing it.
Yes and no @apotterri , what is implemented right now changes the name of the test when it fails, what should be modified is the reason for the error.
So, in reality, even though all the assertions have 'something similar to what we want', it is actually not working at all as we want.
Ah, ok, I see. Thanks.