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

Added argument to setUp and tearDown functions containing name of the… #46

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions doc/shunit2.html
Original file line number Diff line number Diff line change
Expand Up @@ -598,11 +598,13 @@ <h2><a class="toc-backref" href="#id10">Setup/Teardown</a></h2>
<dd><p class="first">This function can be be optionally overridden by the user in their test suite.</p>
<p class="last">If this function exists, it will be called before each test is run. It is
useful to reset the environment before each test.</p>
<p>This function accepts one argument - name of the test that will be executed right after setUp().</p>
</dd>
<dt><tt class="docutils literal">tearDown</tt></dt>
<dd><p class="first">This function can be be optionally overridden by the user in their test suite.</p>
<p class="last">If this function exists, it will be called after each test completes. It is
useful to clean up the environment after each test.</p>
<p>This function accepts one argument - name of the test that has been executed right before this tearDown().</p>
</dd>
</dl>
</div>
Expand Down
6 changes: 6 additions & 0 deletions doc/shunit2.txt
Original file line number Diff line number Diff line change
Expand Up @@ -290,12 +290,18 @@ Setup/Teardown
If this function exists, it will be called before each test is run. It is
useful to reset the environment before each test.

This function accepts one argument - name of the test that will be executed
right after setUp().

``tearDown``
This function can be be optionally overridden by the user in their test suite.

If this function exists, it will be called after each test completes. It is
useful to clean up the environment after each test.

This function accepts one argument - name of the test that has been executed
right before this tearDown().

Skipping
--------

Expand Down
8 changes: 4 additions & 4 deletions shunit2
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@ suite_addTest() {
# Note: see _shunit_mktempFunc() for actual implementation
#
# Args:
# None
# testName Name of the test that will be executed after this setUp
#setUp() { :; } # DO NOT UNCOMMENT THIS FUNCTION

# Note: see _shunit_mktempFunc() for actual implementation
Expand All @@ -727,7 +727,7 @@ suite_addTest() {
# Note: see _shunit_mktempFunc() for actual implementation
#
# Args:
# None
# testName Name of the test after which this tearDown is executed
#tearDown() { :; } # DO NOT UNCOMMENT THIS FUNCTION

#------------------------------------------------------------------------------
Expand Down Expand Up @@ -879,14 +879,14 @@ _shunit_execSuite() {
endSkipping

# Execute the per-test setup function.
setUp
setUp "${_shunit_test_}"

# Execute the test.
echo "${__SHUNIT_TEST_PREFIX}${_shunit_test_}"
eval "${_shunit_test_}"

# Execute the per-test tear-down function.
tearDown
tearDown "${_shunit_test_}"

# Update stats.
if \[ ${__shunit_testSuccess} -eq ${SHUNIT_TRUE} ]; then
Expand Down