From 981384cbbadc2e76bddac76d2337c42f7f0a0b2f Mon Sep 17 00:00:00 2001 From: Jan Stourac Date: Tue, 15 Sep 2015 15:14:14 +0200 Subject: [PATCH] Added argument to setUp and tearDown functions containing name of the relevant test --- source/2.1/doc/shunit2.html | 2 ++ source/2.1/doc/shunit2.txt | 6 ++++++ source/2.1/src/shunit2 | 8 ++++---- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/source/2.1/doc/shunit2.html b/source/2.1/doc/shunit2.html index 3ef771b..249ff42 100644 --- a/source/2.1/doc/shunit2.html +++ b/source/2.1/doc/shunit2.html @@ -598,11 +598,13 @@

Setup/Teardown

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

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().

diff --git a/source/2.1/doc/shunit2.txt b/source/2.1/doc/shunit2.txt index 034c6fc..3b22e8b 100644 --- a/source/2.1/doc/shunit2.txt +++ b/source/2.1/doc/shunit2.txt @@ -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 -------- diff --git a/source/2.1/src/shunit2 b/source/2.1/src/shunit2 index d6e7503..5c7aab8 100755 --- a/source/2.1/src/shunit2 +++ b/source/2.1/src/shunit2 @@ -671,7 +671,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() { :; } # Note: see _shunit_mktempFunc() for actual implementation @@ -683,7 +683,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 #------------------------------------------------------------------------------ @@ -798,14 +798,14 @@ _shunit_execSuite() endSkipping # execute the per-test setup function - setUp + setUp "${_shunit_test_}" # execute the test echo "${_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