-
-
Notifications
You must be signed in to change notification settings - Fork 31
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 unmock function #212
Add unmock function #212
Conversation
src/runner.sh
Outdated
@@ -127,6 +127,7 @@ function runner::run_test() { | |||
"$function_name" "$data" 2>&1 1>&3 | |||
|
|||
runner::run_tear_down | |||
runner::clean_mocks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where are the test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added them to tests/acceptance/mock_test.sh
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we are also missing unit test of the function, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you give me a hint how would you write unit tests for runner::clear_mocks()
?
src/runner.sh
Outdated
@@ -189,6 +190,12 @@ function runner::run_tear_down() { | |||
helper::execute_function_if_exists 'tear_down' | |||
} | |||
|
|||
function runner::clean_mocks() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where are the test?
src/runner.sh
Outdated
@@ -127,6 +127,7 @@ function runner::run_test() { | |||
"$function_name" "$data" 2>&1 1>&3 | |||
|
|||
runner::run_tear_down | |||
runner::clean_mocks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we are also missing unit test of the function, no?
function test_runner_clean_mocks_2() { | ||
assert_is_not_mock ls | ||
assert_is_not_mock ps | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These test are not acceptance test, and the behavior you are trying to test it's not clear
@Chemaclass this is more complex than we anticipated, do you mind if we leave it in draft until we can get together? Besides, I think it's more priority to refactor the acceptance tests and finish the snapshots. |
3340c23
to
cebb41c
Compare
Close because inactivity. I will open it again to seek for new feedback |
📚 Description
Currently, you can mock a particular function with custom logic, but there is no way to rollback the mock for other tests. It would be useful to be able to remove/rollback the mocked behaviour.
🔖 Changes
All mocks will be removed/rollback to their original behaviour after each test.
This means that the mock live scope is tied to the test scope
✅ To-do list
CHANGELOG.md
to reflect the new feature or fix