-
Notifications
You must be signed in to change notification settings - Fork 210
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
Added argument to setUp and tearDown functions containing name of the… #46
base: master
Are you sure you want to change the base?
Conversation
I think that is a nice addition, @kward, is not it? |
981384c
to
069d6ed
Compare
Well, I have rebased this one. Let me know whether there is anything I could improve here. Thx. |
I feel this is not a good addition for a couple of reasons.
If the desired behavior is to have the doSomething() { echo "doSomething() called" >&2; }
# Tests #1 and #2 call doSomething because they need it.
test1() { doSomething; assertTrue ${SHUNIT_TRUE}; }
test2() { doSomething; assertFalse ${SHUNIT_FALSE}; }
# Test #3 does not call doSomething because it doesn't need it.
test3() {assertEquals 1 1; }
source shunit2 Additionally, individual unit tests should only call functions from within the test that setup the environment in some way. Tests should not call cleanup functions. The reasoning is that the cleanup function may never be called due to a failure in the test. Instead, the |
Actually, we use this change just to properly log name of the test that is being executed for our test harness logging mechanism. Also, this change preserved original setUp() and tearDown() functions without arguments, thus no API is broken, actually, for those people who are used to standard declaration of those two functions. Although, I understand your concerns regarding to the possibility to misuse such information for some decision making process. I just saw this as the easiest and straigforward solution for our problem and though it might be useful also for somebody else. |
If you are looking to log that info, I think a better option would be to add logging hooks that are disabled by default (just like I'd do it just before calling and just after Thoughts? If you like that idea, would you want to code that up? |
Maybe a single logging hook, where you pass to it what phase you are logging, as well as the function name? |
@jstourac , I see that $shunit_test is already visible in setUp() |
Refactor code to make it easier to test a full deployment. - leverage shUnit2's `setUp` and `tearDown` functions to setup a few things - also introduce a `test::utils::setupFixture` function that copies a fixture into the container's HOME directory. This follows advice from shUnit2's developer: kward/shunit2#46 - add a more precise namespace to `test::` functions - introduce new tests (`test::legacy::php8x`)
… relevant test