Skip to content

Commit

Permalink
Added argument to setUp and tearDown functions containing name of the…
Browse files Browse the repository at this point in the history
… relevant test
  • Loading branch information
jstourac committed Jan 12, 2018
1 parent 1b7ba3a commit 069d6ed
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
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

0 comments on commit 069d6ed

Please sign in to comment.