Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add third optional parameter on asserts #77

Open
khru opened this issue Sep 13, 2023 · 5 comments
Open

Add third optional parameter on asserts #77

khru opened this issue Sep 13, 2023 · 5 comments
Labels
bug Something isn't working good first issue Good for newcomers hacktoberfest

Comments

@khru
Copy link
Member

khru commented Sep 13, 2023

Add 3º parameter optional that will override the error message Ex.: phpunit

@khru khru added the enhancement New feature or request label Sep 13, 2023
@Chemaclass
Copy link
Member

This is already for assertEquals. Or on which functions do you mean?

@antonio-gg-dev
Copy link
Member

@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.

@antonio-gg-dev antonio-gg-dev changed the title Add third optional parameter Add third optional parameter on asserts Sep 14, 2023
@Chemaclass Chemaclass added bug Something isn't working and removed enhancement New feature or request labels Sep 15, 2023
@apotterri
Copy link
Contributor

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.

@antonio-gg-dev
Copy link
Member

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.

@apotterri
Copy link
Contributor

Ah, ok, I see. Thanks.

@Chemaclass Chemaclass added the good first issue Good for newcomers label Jun 17, 2024
@Chemaclass Chemaclass moved this to Todo in bashunit Sep 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers hacktoberfest
Projects
Status: Todo
Development

No branches or pull requests

4 participants