::xounit::test
Class TestTestResult

Heritage:
::xotcl::Object
  |
  +--::xox::Node
        |
        +--::xounit::Test
              |
              +--::xounit::Assert
                    |
                    +--::xounit::TestCase
Tested Class:
::xounit::TestResult

Class TestTestResult
superclass ::xounit::TestCase,

Variables
NameDefault ValueClassComment
currentTestMethod    ::xounit::TestCase
 name of the currently running test method.
nodeName    ::xox::Node
 
result    ::xounit::TestCase
 the result for the current run.
 
Methods
NameComment
testAddError {}  
testAddFailure {}  
testAddPass {}  
testAddResult {}  
testAddResultAddFailure {}  
testInit {}  
testMessage {}  
testPercent {}  
testPrint {}  
testPrintEmail {}  
testPrintWeb {}  
testTestedClassTestedMethod {}  
testTree {}  
   
Methods from ::xotcl::Object
#, ., ?, ?code, ?methods, ?object, abstract, copy, coverageFilter, defaultmethod, extractConfigureArg, filterappend, garbageCollect, get#, getClean#, hasclass, init, methodTag, mixinappend, move, profileFilter, self, setParameterDefaults, shell, tclcmd, traceFilter,
 
Instproc Detail

testAddError

Description:
 
Code:
  ::xounit::test::TestTestResult instproc testAddError {}  {
   

        set result [ ::xounit::TestResult new -name TestResult ]

        $result addResult [ ::xounit::TestError new -name 1 -test 2 -error 3 ]

        my assertEquals [ llength [ $result passes ] ] 0 
        my assertEquals [ llength [ $result results ] ] 1 
        my assertEquals [ llength [ $result errors ] ] 1 
        my assertEquals [ llength [ $result failures ] ] 0 
        my assertFalse [ $result passed ]
    
}

testAddFailure

Description:
 
Code:
  ::xounit::test::TestTestResult instproc testAddFailure {}  {
   

        set result [ ::xounit::TestResult new -name TestResult ]

        $result addResult [ ::xounit::TestFailure new -name 1 -test 2 -error 3 ] 

        my assertEquals [ llength [ $result passes ] ] 0 
        my assertEquals [ llength [ $result results ] ] 1 
        my assertEquals [ llength [ $result errors ] ] 0 
        my assertEquals [ llength [ $result failures ] ] 1 
        my assertFalse [ $result passed ]
    
}

testAddPass

Description:
 
Code:
  ::xounit::test::TestTestResult instproc testAddPass {}  {
   

        set result [ ::xounit::TestResult new -name TestResult ]

        $result addResult [ ::xounit::TestPass new -name 1 -test 2 -return 3 ] 
        my assertEquals [ llength [ $result passes ] ] 1 
        my assertEquals [ llength [ $result results ] ] 1 
        my assertEquals [ llength [ $result errors ] ] 0 
        my assertEquals [ llength [ $result failures ] ] 0 
        my assert [ $result passed ]
    
}

testAddResult

Description:
 
Code:
  ::xounit::test::TestTestResult instproc testAddResult {}  {
   

        set result [ ::xounit::TestResult new -name TestResult ]

        $result addResult [ ::xounit::TestResult new -name SubResult ]

        my assertEquals [ llength [ $result passes ] ] 0 
        my assertEquals [ llength [ $result results ] ] 1 
        my assertEquals [ llength [ $result errors ] ] 0 
        my assertEquals [ llength [ $result failures ] ] 0 
        my assert [ $result passed ]
    
}

testAddResultAddFailure

Description:
 
Code:
  ::xounit::test::TestTestResult instproc testAddResultAddFailure {}  {
   

        set result [ ::xounit::TestResult new -name TestResult ]
        set subResult [ ::xounit::TestResult new -name SubResult ]
        set subResult [ $result addResult $subResult ]
        $subResult addResult [ ::xounit::TestFailure new -name 1 -test 2 -error 3 ]

        my assertEquals [ llength [ $result passes ] ] 0 
        my assertEquals [ llength [ $result results ] ] 1 
        my assertEquals [ llength [ $result errors ] ] 0 
        my assertEquals [ llength [ $result failures ] ] 0 
        my assertFalse [ $result passed ]

        my assertEquals [ llength [ $subResult passes ] ] 0 
        my assertEquals [ llength [ $subResult results ] ] 1 
        my assertEquals [ llength [ $subResult errors ] ] 0 
        my assertEquals [ llength [ $subResult failures ] ] 1 
        my assertFalse [ $subResult passed ]
    
}

testInit

Description:
 
Code:
  ::xounit::test::TestTestResult instproc testInit {}  {
   

        set result [ ::xounit::TestResult new -name TestResult ]

        my assertEquals [ $result name ] TestResult
        my assertEquals [ $result results ] ""
    
}

testMessage

Description:
 
Code:
  ::xounit::test::TestTestResult instproc testMessage {}  {
   

        set pass [ ::xounit::TestPass new -name Pass  -return message ]
        my assertEquals [ $pass message ] message
        set fail [ ::xounit::TestFailure new -name Failure  -error message ]
        my assertEquals [ $fail message ] message
        set error [ ::xounit::TestError new -name Error  -error message ]
        my assertEquals [ $error message ] message
    
}

testPercent

Description:
 
Code:
  ::xounit::test::TestTestResult instproc testPercent {}  {
   

        set a [ ::xounit::TestResult new -name A ]

        $a addResult [ ::xounit::TestPass new -name P1 ]

        my assertEquals [ $a passPercent ] 100

        $a addResult [ ::xounit::TestFailure new -name F1 ]

        my assertEquals [ $a passPercent ] 50

        $a addResult [ ::xounit::TestError new -name E1 ]

        my assertEquals [ expr { int( [ $a passPercent ] ) } ] 33
    
}

testPrint

Description:
 
Code:
  ::xounit::test::TestTestResult instproc testPrint {}  {
   

        set result [ ::xounit::TestResult new -name TestResult ]
        set subResult [ ::xounit::TestResult new -name SubResult ]
        set subResult [ $result addResult $subResult ]
        $subResult addResult [ ::xounit::TestFailure new -name 1 -test 2 -error 3 ]
        set newResult [ ::xounit::TestResult new -name SubResult ]
        set newResult [ $subResult addResult $newResult ]
        set subResult $newResult
        set newResult [ ::xounit::TestResult new -name SubResult ]
        set newResult [ $subResult addResult $newResult ]
        set subResult $newResult
        set newResult [ ::xounit::TestResult new -name SubResult ]
        set newResult [ $subResult addResult $newResult ]
        set subResult $newResult
        $subResult addResult [ ::xounit::TestFailure new -name 1 -test 2 -error 3 ]

        set formatter [ ::xounit::TestResultsTextFormatter new ]

        puts "\n\n"
        $formatter printResults $result

        return ""
    
}

testPrintEmail

Description:
 
Code:
  ::xounit::test::TestTestResult instproc testPrintEmail {}  {
   

        set result [ ::xounit::TestResult new -name TestResult ]
        set subResult [ ::xounit::TestResult new -name SubResult ]
        set subResult [ $result addResult $subResult ]
        $subResult addResult [ ::xounit::TestFailure new -name 1 -test 2 -error 3 ]
        set newResult [ ::xounit::TestResult new -name SubResult ]
        set newResult [ $subResult addResult $newResult ]
        set subResult $newResult
        set newResult [ ::xounit::TestResult new -name SubResult ]
        set newResult [ $subResult addResult $newResult ]
        set subResult $newResult
        set newResult [ ::xounit::TestResult new -name SubResult ]
        set newResult [ $subResult addResult $newResult ]
        set subResult $newResult
        $subResult addResult [ ::xounit::TestFailure new -name 1 -test 2 -error 3 ]

        set formatter [ ::xounit::TestResultsEmailFormatter new ]

        puts "\n\n"
        $formatter printResults $result

        return ""
    
}

testPrintWeb

Description:
 
Code:
  ::xounit::test::TestTestResult instproc testPrintWeb {}  {
   

        set result [ ::xounit::TestResult new -name TestResult ]
        set subResult [ ::xounit::TestResult new -name SubResult ]
        set subResult [$result addResult $subResult ]
        $subResult addResult [ ::xounit::TestFailure new -name 1 -test 2 -error 3 ]
        set newResult [ ::xounit::TestResult new -name SubResult ]
        set newResult [ $subResult addResult $newResult ]
        set subResult $newResult
        set newResult [ ::xounit::TestResult new -name SubResult ]
        set newResult [ $subResult addResult $newResult ]
        set subResult $newResult
        set newResult [ ::xounit::TestResult new -name SubResult ]
        set newResult [ $subResult addResult $newResult ]
        set subResult $newResult
        $subResult addResult [ ::xounit::TestFailure new -name 1 -test 2 -error 3 ]

        set formatter [ ::xounit::TestResultsWebFormatter new ]

        puts "\n\n"
        $formatter printResults $result

        return ""
    
}

testTestedClassTestedMethod

Description:
 
Code:
  ::xounit::test::TestTestResult instproc testTestedClassTestedMethod {}  {
   

        Class  ::xounit::TestClassTestedClass -superclass ::xounit::TestCase

        ::xounit::TestClassTestedClass instproc testMethodPass { } {

        }

        ::xounit::TestClassTestedClass instproc testMethodFail { } {

            my fail "fail"
        }

        ::xounit::TestClassTestedClass instproc testMethodError { } {

            error error
        }

        set test [ ::xounit::TestClassTestedClass new ]

        set result [ $test runAlone ]

        my assertEquals [ $result info class ] ::xounit::TestResult
        my assertEquals [ $result name ] ::xounit::TestClassTestedClass 

        set pass [ $result passes ]

        my assertEquals [ $pass info class ] ::xounit::TestPass
        my assertEquals [ $pass name ] ::xounit::TestClassTestedClass 
        my assertEquals [ $pass test ] testMethodPass
        my assertEquals [ $pass testedClass ] ::xounit::TestClassTestedClass
        my assertEquals [ $pass testedMethod ] testMethodPass

        set failure [ $result failures ]

        my assertEquals [ $failure info class ] ::xounit::TestFailure
        my assertEquals [ $failure name ] ::xounit::TestClassTestedClass 
        my assertEquals [ $failure test ] testMethodFail
        my assertEquals [ $failure testedClass ] ::xounit::TestClassTestedClass
        my assertEquals [ $failure testedMethod ] testMethodFail

        set error [ $result errors ]

        my assertEquals [ $error info class ] ::xounit::TestError
        my assertEquals [ $error name ] ::xounit::TestClassTestedClass 
        my assertEquals [ $error test ] testMethodError
        my assertEquals [ $error testedClass ] ::xounit::TestClassTestedClass
        my assertEquals [ $error testedMethod ] testMethodError
    
}

testTree

Description:
 
Code:
  ::xounit::test::TestTestResult instproc testTree {}  {
   

        set a [ ::xounit::TestResult new -name A ]
        set b [ ::xounit::TestResult new -name B ]
        set c [ ::xounit::TestResult new -name C ]
        set d [ ::xounit::TestResult new -name D ]
        
        set p1 [ ::xounit::TestPass new -name P1 ]
        set p2 [ ::xounit::TestPass new -name P2 ]
        set p3 [ ::xounit::TestPass new -name P3 ]

        set f1 [ ::xounit::TestFailure new -name F1 ]
        set f2 [ ::xounit::TestFailure new -name F2 ]
        set f3 [ ::xounit::TestFailure new -name F3 ]

        set e1 [ ::xounit::TestError new -name E1 ]
        set e2 [ ::xounit::TestError new -name E2 ]
        set e3 [ ::xounit::TestError new -name E3 ]

        set b [  $a addResult $b ]
        set c [ $a addResult $c ]
        set d [ $c addResult $d ]

        set p1 [ $a addResult $p1 ]
        set p2 [ $b addResult $p2 ]
        set p3 [ $c addResult $p3 ]

        set f1 [ $b addResult $f1 ]
        set f2 [ $c addResult $f2 ]
        set f3 [ $d addResult $f3 ]

        set e1 [ $a addResult $e1 ]
        set e2 [ $b addResult $e2 ]
        set e3 [ $d addResult $e3 ]

        set passes [ $a deepPasses ]
        set errors [ $a deepErrors ]
        set failures [ $a deepFailures ]

        my assertObjectInList $passes $p1
        my assertObjectInList $passes $p2
        my assertObjectInList $passes $p3

        my assertObjectInList $errors $e1
        my assertObjectInList $errors $e2
        my assertObjectInList $errors $e3

        my assertObjectInList $failures $f1
        my assertObjectInList $failures $f2
        my assertObjectInList $failures $f3

        set passes [ $b deepPasses ]
        set errors [ $b deepErrors ]
        set failures [ $b deepFailures ]

        my assertObjectInList $passes $p2 
        my assertObjectInList $failures $f1 

        set passes [ $c deepPasses ]
        set errors [ $c deepErrors ]
        set failures [ $c deepFailures ]

        my assertObjectInList $passes $p3
        my assertObjectInList $failures $f2 
        my assertObjectInList $failures $f3
        my assertObjectInList $errors $e3

        set passes [ $d deepPasses ]
        set errors [ $d deepErrors ]
        set failures [ $d deepFailures ]

        my assertObjectInList $failures $f3
        my assertObjectInList $errors $e3

        my assertEquals [ $a path ] "TestResult"
        my assertEquals [ $b path ] "TestResult / TestResult"
        my assertEquals [ $c path ] "TestResult / TestResult_0"
        my assertEquals [ $d path ] "TestResult / TestResult_0 / TestResult"
        my assertEquals [ $p1 path ] "TestResult / TestPass"
        my assertEquals [ $p2 path ] "TestResult / TestResult / TestPass"
        my assertEquals [ $p3 path ] "TestResult / TestResult_0 / TestPass"
        my assertEquals [ $f1 path ] "TestResult / TestResult / TestFailure"
        my assertEquals [ $f2 path ] "TestResult / TestResult_0 / TestFailure"
        my assertEquals [ $f3 path ] "TestResult / TestResult_0 / TestResult / TestFailure"
        my assertEquals [ $e1 path ] "TestResult / TestError"
        my assertEquals [ $e2 path ] "TestResult / TestResult / TestError"
        my assertEquals [ $e3 path ] "TestResult / TestResult_0 / TestResult / TestError"
    
}