From: lacton <la...@us...> - 2008-03-25 21:43:55
|
Update of /cvsroot/shunit/ShUnit In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv5439 Modified Files: shUnit shUnitAcceptanceTest shuXmlFormatter Added Files: OneFailingTest Log Message: [add] XML output for 1 failing test. --- NEW FILE: OneFailingTest --- #! /usr/bin/env sh FailingTest() { shuAssert 'Intentional failure' 1 } Suite() { shuRegTest FailingTest; } . "$SHUNIT_HOME/shUnit" shuStart Suite Index: shUnitAcceptanceTest =================================================================== RCS file: /cvsroot/shunit/ShUnit/shUnitAcceptanceTest,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** shUnitAcceptanceTest 24 Mar 2008 21:49:39 -0000 1.4 --- shUnitAcceptanceTest 25 Mar 2008 21:43:50 -0000 1.5 *************** *** 21,24 **** --- 21,25 ---- shuRegTest TestShuStartWith2Arguments shuRegTest TestXmlOutputWithOneSuccessfulTest + shuRegTest TestXmlOutputWithOneFailingTest shuRegTest TestXmlOutputWithTwoSuccessfulTests } *************** *** 174,177 **** --- 175,201 ---- } + TestXmlOutputWithOneFailingTest() { + for shell in $available_shells + do + $shell shuXmlFormatter ./OneFailingTest + expectedXml="<?xml version=\"1.0\" ?> + <testsuite errors=\"0\" failures=\"1\" hostname=\"`hostname`\" name=\"OneFailingTest\" tests=\"1\"> + <testcase classname=\"OneFailingTest\" name=\"FailingTest\"> + <failure message=\"Intentional failure\"> + Intentional failure at OneFailingTest.FailingTest(./OneFailingTest) + </failure> + </testcase> + <system-out><![CDATA[]]></system-out> + <system-err><![CDATA[]]></system-err> + </testsuite>" + [ -f TEST-OneFailingTest.xml ] + shuAssert "XML file created" $? + actualXml=`cat TEST-OneFailingTest.xml` + [ "$expectedXml" = "$actualXml" ] + shuAssert "XML contents as expected" $? + rm -f TEST-OneFailingTest.xml + done + } + TestXmlOutputWithTwoSuccessfulTests() { for shell in $available_shells Index: shuXmlFormatter =================================================================== RCS file: /cvsroot/shunit/ShUnit/shuXmlFormatter,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** shuXmlFormatter 24 Mar 2008 21:49:39 -0000 1.2 --- shuXmlFormatter 25 Mar 2008 21:43:50 -0000 1.3 *************** *** 8,12 **** exec > TEST-$suiteName.xml echo "<?xml version=\"1.0\" ?>" - echo "<testsuite errors=\"0\" failures=\"0\" hostname=\"`hostname`\" name=\"$suiteName\" tests=\"$testCount\">" } --- 8,11 ---- *************** *** 17,21 **** shuTestFailure() { ! : } --- 16,20 ---- shuTestFailure() { ! failureMessage="$1" } *************** *** 25,32 **** shuTestEnd() { ! echo " <testcase classname=\"$suiteName\" name=\"$testName\" />" } shuSuiteEnd() { echo " <system-out><![CDATA[]]></system-out>" echo " <system-err><![CDATA[]]></system-err>" --- 24,46 ---- shuTestEnd() { ! if [ "$failureMessage" = "" ] ! then ! body="$body <testcase classname=\"$suiteName\" name=\"$testName\" /> ! " ! else ! body="$body <testcase classname=\"$suiteName\" name=\"$testName\"> ! <failure message=\"$failureMessage\"> ! $failureMessage at $suiteName.$testName($testScript) ! </failure> ! </testcase> ! " ! fi ! unset failureMessage } shuSuiteEnd() { + shuFailedTestCount=$1 + echo "<testsuite errors=\"0\" failures=\"$shuFailedTestCount\" hostname=\"`hostname`\" name=\"$suiteName\" tests=\"$testCount\">" + printf "$body" echo " <system-out><![CDATA[]]></system-out>" echo " <system-err><![CDATA[]]></system-err>" Index: shUnit =================================================================== RCS file: /cvsroot/shunit/ShUnit/shUnit,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** shUnit 24 Mar 2008 21:49:39 -0000 1.27 --- shUnit 25 Mar 2008 21:43:50 -0000 1.28 *************** *** 121,125 **** shuFailedTestCount=`expr ${shuTestNbr} - ${SHU_TOTAL_NR_SUCCEEDED}` ! shuSuiteEnd if [ $shuFailedTestCount -lt $SHU_ERROR_EXIT_CODE ] --- 121,125 ---- shuFailedTestCount=`expr ${shuTestNbr} - ${SHU_TOTAL_NR_SUCCEEDED}` ! shuSuiteEnd $shuFailedTestCount if [ $shuFailedTestCount -lt $SHU_ERROR_EXIT_CODE ] *************** *** 139,143 **** SHU_STR_FAILED="${SHU_STR_FAILED}^${msg}" fi - SHU_TEST_SUCCEEDED=${SHU_FALSE} } --- 139,142 ---- *************** *** 149,152 **** --- 148,152 ---- then shuTestFailure "${strMessage}" + SHU_TEST_SUCCEEDED=${SHU_FALSE} # TODO Duplication else shuTestSuccess *************** *** 161,164 **** --- 161,165 ---- then shuTestFailure "${strMessage}" + SHU_TEST_SUCCEEDED=${SHU_FALSE} # TODO Duplication else shuTestSuccess *************** *** 211,214 **** --- 212,216 ---- then shuSuiteEnd() { + shuFailedTestCount=$1 shuFmtNbrTests "${shuTestNbr}" printf "\n%s run.\n" "${shuRetFmtNbrTests}" |