::xounit
Class TestResult

Heritage:
::xotcl::Object
  |
  +--::xox::Node
Direct Known Subclasses:
::xounit::TestError, ::xounit::TestFailure, ::xounit::TestPass,

Associated Test:
::xounit::test::TestTestResult

Class TestResult
superclass ::xox::Node,
TestResult is an aggregation of smaller test results.  
 It contains all the TestPass and TestFailure objects that
 are recorded from running a test.
Variables
NameDefault ValueClassComment
name  unnamed  ::xounit::TestResult
 name of the test
nodeName    ::xox::Node
 
testedClass  ""  ::xounit::TestResult
 the class tested
testedMethod  ""  ::xounit::TestResult
 the method tested
testedObject  ""  ::xounit::TestResult
 the object tested
 
Methods
NameComment
addNewResult {class args}  
addResult {result}   Adds a subresult to the current TestResult in the result-tree
deepErrors {}   Returns all TestErrors that are in the subtree under this TestResult
deepFailures {}   Returns all TestFailures that are in the subtree under this TestResult
deepPasses {}   Returns all TestPasses that are in the subtree under this TestResult
errors {}   Returns all TestErrors that are direct children of this TestResult
failures {}   Returns all TestFailures that are direct children of this TestResult
numberOfErrors {}   returns the number of errors in this TestResult
numberOfFailures {}   returns the number of failures in this TestResult
numberOfPasses {}   returns the number of passes in this TestResult
numberOfTests {}   returns the number of tests in this TestResult
passPercent {}   returns the percentage of tests that passed
passed {}   returns 1 only if there are no failures or errors in this TestResult
passes {}   Returns all TestPasses that are direct children of this TestResult
results {}  
tests {}   returns all tests in this TestResult
   
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

addNewResult

Description:
 
Arguments:
Code:
  ::xounit::TestResult instproc addNewResult {class args}  {
   

        #my debug $args

        return [ my createAutoNamedChildInternal $class $args ]
    
}

addResult

Description:
 Adds a subresult to the current TestResult in the result-tree.
Arguments:
Code:
  ::xounit::TestResult instproc addResult {result}  {
   

        return [ my addAutoNameNode $result ]
    
}

deepErrors

Description:
 Returns all TestErrors that are in the subtree under
 this TestResult.
Code:
  ::xounit::TestResult instproc deepErrors {}  {
   

        set errors ""

        foreach result [ my results ] {

            if [ $result hasclass ::xounit::TestFailure ] { continue }
            if [ $result hasclass ::xounit::TestPass ] { continue }
            if [ $result hasclass ::xounit::TestError ] {

                lappend errors $result
                continue
            }
            set errors [ concat $errors [ $result deepErrors ] ]
        }
        return $errors
    
}

deepFailures

Description:
 Returns all TestFailures that are in the subtree under
 this TestResult.
Code:
  ::xounit::TestResult instproc deepFailures {}  {
   

        set failures ""

        foreach result [ my results ] {

            if [ $result hasclass ::xounit::TestError ] { continue }
            if [ $result hasclass ::xounit::TestPass ] { continue }
            if [ $result hasclass ::xounit::TestFailure ] {

                lappend failures $result
                continue
            }
            set failures [ concat $failures [ $result deepFailures ] ]
        }
        return $failures
    
}

deepPasses

Description:
 Returns all TestPasses that are in the subtree under
 this TestResult.
Code:
  ::xounit::TestResult instproc deepPasses {}  {
   

        set passes ""

        foreach result [ my results ] {

            if [ $result hasclass ::xounit::TestFailure ] { continue }
            if [ $result hasclass ::xounit::TestError ] { continue }
            if [ $result hasclass ::xounit::TestPass ] {

                lappend passes $result
                continue
            }
            set passes [ concat $passes [ $result deepPasses ] ]
        }
        return $passes
    
}

errors

Description:
 Returns all TestErrors that are direct children
 of this TestResult.
Code:
  ::xounit::TestResult instproc errors {}  {
   

        set errors ""

        foreach result [ my results ] {

            if [ $result hasclass ::xounit::TestError ] {

                lappend errors $result

            }
        }
        return $errors
    
}

failures

Description:
 Returns all TestFailures that are direct children
 of this TestResult.
Code:
  ::xounit::TestResult instproc failures {}  {
   

        set failures ""

        foreach result [ my results ] {

            if [ $result hasclass ::xounit::TestFailure ] {

                lappend failures $result

            }
        }
        return $failures
    
}

numberOfErrors

Description:
 returns the number of errors in this TestResult
Code:
  ::xounit::TestResult instproc numberOfErrors {}  {
   

        set errors 0

        foreach result [ my results ] {

            incr errors [ $result numberOfErrors ]
        }

        return $errors
    
}

numberOfFailures

Description:
 returns the number of failures in this TestResult
Code:
  ::xounit::TestResult instproc numberOfFailures {}  {
   
 
        set failures 0

        foreach result [ my results ] {

            incr failures [ $result numberOfFailures ]
        }

        return $failures
    
}

numberOfPasses

Description:
 returns the number of passes in this TestResult
Code:
  ::xounit::TestResult instproc numberOfPasses {}  {
   

        set passes 0

        foreach result [ my results ] {

            incr passes [ $result numberOfPasses ]
        }

        return $passes
    
}

numberOfTests

Description:
 returns the number of tests in this TestResult
Code:
  ::xounit::TestResult instproc numberOfTests {}  {
   
 
        set tests 0

        foreach result [ my results ] {

            incr tests [ $result numberOfTests ]
        }

        return $tests
    
}

passPercent

Description:
 returns the percentage of tests that passed.
Code:
  ::xounit::TestResult instproc passPercent {}  {
   

        set total [ my numberOfTests ]
        set passes [ my numberOfPasses ]
        
        if { $total == 0 } { return 0.0 }

        return [ expr 100.0 * $passes / $total ]
    
}

passed

Description:
 returns 1 only if there are no failures or errors
 in this TestResult. returns 0 otherwise
Code:
  ::xounit::TestResult instproc passed {}  {
   

        foreach result [ my results ] {

            if { ! [ $result passed ] } {

                return 0
            }
        }

        return 1
    
}

passes

Description:
 Returns all TestPasses that are direct children
 of this TestResult.
Code:
  ::xounit::TestResult instproc passes {}  {
   

        set passes ""

        foreach result [ my results ] {

            if [ $result hasclass ::xounit::TestPass ] {

                lappend passes $result
            }
        }
        return $passes
    
}

results

Description:
 
Code:
  ::xounit::TestResult instproc results {}  {
   

        return [ ::xox::removeIfNot {

            $result hasclass ::xounit::TestResult
        } result [ my info children ] ]
    
}

tests

Description:
 returns all tests in this TestResult.
 returns all errors, failures, and passes
Code:
  ::xounit::TestResult instproc tests {}  {
   

        return [ concat [ my errors ] [ my failures ] [ my passes ] ]
    
}