From: lacton <la...@us...> - 2008-03-16 15:44:55
|
Update of /cvsroot/shunit/ShUnit In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv21883 Modified Files: shUnit shUnitTest Added Files: autoSuiteTest Log Message: [add] Auto-detection of all test functions that begin with 'Test'. Index: shUnitTest =================================================================== RCS file: /cvsroot/shunit/ShUnit/shUnitTest,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** shUnitTest 31 Dec 2005 06:35:29 -0000 1.16 --- shUnitTest 16 Mar 2008 15:44:50 -0000 1.17 *************** *** 122,125 **** --- 122,133 ---- } + TestAutoSuite() { + std_output=`./autoSuiteTest` + echo "$std_output" | grep -q 'NotATest' + shuDeny "Auto-detected suite should not include NotATest" $? + echo "$std_output" | grep -q 'Test1' + shuAssert "Auto-detected suite should include Test1" $? + } + InitFunction() { shuRegTest TestIntentionalFailure *************** *** 131,134 **** --- 139,143 ---- shuRegTest TestSetupCalledCorrectly shuRegTest TestShuFmtNbrTests + shuRegTest TestAutoSuite } Index: shUnit =================================================================== RCS file: /cvsroot/shunit/ShUnit/shUnit,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** shUnit 18 Mar 2006 04:53:18 -0000 1.14 --- shUnit 16 Mar 2008 15:44:50 -0000 1.15 *************** *** 26,33 **** # in which your test will be run # 4. Again in the 'main', call the shuStart function with the name of the initialization ! # function as an argument. # 5. For each testfunction, perform these steps: # 5.1. Add a line to the initialization function to register the testfunction. This ! # will look like: shuRegTest NameOfTestFunction # 5.2. Create a function NameOfTestFuction that # 5.2.1. executes whatever you wish to test --- 26,35 ---- # in which your test will be run # 4. Again in the 'main', call the shuStart function with the name of the initialization ! # function as an argument, or no argument at all if all your test functions ! # begin with 'Test'. # 5. For each testfunction, perform these steps: # 5.1. Add a line to the initialization function to register the testfunction. This ! # will look like: shuRegTest NameOfTestFunction. Skip this step if all ! # your test functions begin with 'Test'. # 5.2. Create a function NameOfTestFuction that # 5.2.1. executes whatever you wish to test *************** *** 92,96 **** strInitFunction="${1}" ! eval ${strInitFunction} printf "\n****** `basename ${0}` ******\n" --- 94,106 ---- strInitFunction="${1}" ! if [ $# -eq 1 ] ! then ! eval ${strInitFunction} ! else ! for test_function in `declare -F | sed -n 's/declare -f Test/Test/p'` ! do ! shuRegTest "$test_function" ! done ! fi printf "\n****** `basename ${0}` ******\n" --- NEW FILE: autoSuiteTest --- #! /usr/bin/env sh # # This dummy test script illustrates how to use the test suite auto-detection features. # It is called by shUnitTest as part of the framework's regression test. # # # find the shUnit file using the command as a reference # inherit() { d=`expr ${0} : '\([a-zA-Z/._-]*\/\)'` test `expr "$d" : '[./]'` -eq 0 && d="./$d" . ${d}${1} } inherit shUnit NotATest() { : } Test1() { shuAssert "Always true" 0 } ### Main shuStart |