Skip to content

Commit 981384c

Browse files
committed
Added argument to setUp and tearDown functions containing name of the relevant test
1 parent 60dd60b commit 981384c

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

source/2.1/doc/shunit2.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -598,11 +598,13 @@ <h2><a class="toc-backref" href="#id10">Setup/Teardown</a></h2>
598598
<dd><p class="first">This function can be be optionally overridden by the user in their test suite.</p>
599599
<p class="last">If this function exists, it will be called before each test is run. It is
600600
useful to reset the environment before each test.</p>
601+
<p>This function accepts one argument - name of the test that will be executed right after setUp().</p>
601602
</dd>
602603
<dt><tt class="docutils literal">tearDown</tt></dt>
603604
<dd><p class="first">This function can be be optionally overridden by the user in their test suite.</p>
604605
<p class="last">If this function exists, it will be called after each test completes. It is
605606
useful to clean up the environment after each test.</p>
607+
<p>This function accepts one argument - name of the test that has been executed right before this tearDown().</p>
606608
</dd>
607609
</dl>
608610
</div>

source/2.1/doc/shunit2.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,12 +290,18 @@ Setup/Teardown
290290
If this function exists, it will be called before each test is run. It is
291291
useful to reset the environment before each test.
292292

293+
This function accepts one argument - name of the test that will be executed
294+
right after setUp().
295+
293296
``tearDown``
294297
This function can be be optionally overridden by the user in their test suite.
295298

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

302+
This function accepts one argument - name of the test that has been executed
303+
right before this tearDown().
304+
299305
Skipping
300306
--------
301307

source/2.1/src/shunit2

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,7 @@ suite_addTest()
671671
# Note: see _shunit_mktempFunc() for actual implementation
672672
#
673673
# Args:
674-
# None
674+
# testName Name of the test that will be executed after this setUp
675675
#setUp() { :; }
676676

677677
# Note: see _shunit_mktempFunc() for actual implementation
@@ -683,7 +683,7 @@ suite_addTest()
683683
# Note: see _shunit_mktempFunc() for actual implementation
684684
#
685685
# Args:
686-
# None
686+
# testName Name of the test after which this tearDown is executed
687687
#tearDown() { :; } # DO NOT UNCOMMENT THIS FUNCTION
688688

689689
#------------------------------------------------------------------------------
@@ -798,14 +798,14 @@ _shunit_execSuite()
798798
endSkipping
799799

800800
# execute the per-test setup function
801-
setUp
801+
setUp "${_shunit_test_}"
802802

803803
# execute the test
804804
echo "${_shunit_test_}"
805805
eval ${_shunit_test_}
806806

807807
# execute the per-test tear-down function
808-
tearDown
808+
tearDown "${_shunit_test_}"
809809

810810
# update stats
811811
if [ ${__shunit_testSuccess} -eq ${SHUNIT_TRUE} ]; then

0 commit comments

Comments
 (0)