-
-
Notifications
You must be signed in to change notification settings - Fork 29
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
Example on how to test a function #233
Comments
Hello @pmusset ! First of all, thank you very much for using bashunit! You are correct, you should add
This way, all the functions within the file will be loaded from scratch before each test inside that file is executed. In the example you mentioned, we are not using source because bashunit uses itself for testing, so it doesn't need to import its own functions as they have already been imported previously in the runtime. But the standard is to have to do it. I hope I have resolved your doubts and if you have any other questions do not hesitate to let us know. |
I also wanted to thank you for giving us feedback on the example @pmusset . You are absolutely right. I will add it as soon as possible, but if you want, you can do it yourself and make us a PR, we would really appreciate it a lot. |
Thanks to both of you. Now I understand better. So that also means that the file that is sourced shouldn't contain any code that will execute when it is sourced, right ? |
@pmusset, that would depend on the way you are designing your logic. My personal preference:
|
Closed as the question was answered and the example code was improved here #234 |
In the examples here, I think it misses one that shows how to test a specific function in a script.
For example, in a directory organised like that, as describe in your quickstart guide,
I am not sure what I have to write in
example_test.sh
to test a function inexample.sh
. Should I sourceexample.sh
? But according to your own tests (for example here) it doesn't seem to be the case.The text was updated successfully, but these errors were encountered: