::xounit::test
Class TestTestCase

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

Class TestTestCase
superclass ::xounit::TestCase,

Variables
NameDefault ValueClassComment
aTestVariable    ::xounit::test::TestTestCase
 
currentTestMethod    ::xounit::TestCase
 name of the currently running test method.
nodeName    ::xox::Node
 
result    ::xounit::TestCase
 the result for the current run.
 
Methods
NameComment
setUp {}   setUp is called before each test method in your specific test case
tearDown {}   tearDown is called after each test method in your specific test case
test {}  
testError {}  
testFailure {}  
testPass {}  
testReturnValue {}  
testTestCase {}  
testtestReturnValue {}  
   
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

setUp

Description:
 setUp is called before each test method in
 your specific test case.  This provides a clean
 test fixture for each test method.  Over-ride 
 setUp in your specific TestCase to configure
 your TestCase before each test.  Example:

 SimpleTest instproc setUp {} {

     my set testValue 10
 }

 SimpleTest instproc testValue {} {

     my assertEquals [ my set testValue ] 10
 }
Overrides:
setUp in ::xounit::TestCase
Code:
  ::xounit::test::TestTestCase instproc setUp {}  {
   

        my aTestVariable 5
    
}

tearDown

Description:
 tearDown is called after each test method
 in your specific test case.  This allows
 you to clean up any resources that were used
 in your test methods. Override this method
 in your TestCase and it will automatically
 called after each test method.
Overrides:
tearDown in ::xounit::TestCase
Code:
  ::xounit::test::TestTestCase instproc tearDown {}  {
   

        my unset aTestVariable 

        my assertFalse [ my exists aTestVariable ] { Should have unset aTestVariable }
    
}

test

Description:
 
Code:
  ::xounit::test::TestTestCase instproc test {}  {
   

        set test [ ::xounit::TestCase new ]

        my assertEquals [ $test name ] ::xounit::TestCase

        #my assertEquals [ $test toString ] ""
    
}

testError

Description:
 
Code:
  ::xounit::test::TestTestCase instproc testError {}  {
   

        set testCase [ ::xounit::TestCase new A ]

        $testCase proc testError { } {

            error 3
        }

        set result [ $testCase runAlone ]

        my assertFalse [ $result passed ]
        set sub [ $result results ]

        my assertEquals [ $result name ] ::xounit::TestCase
        my assertEquals [ $sub name ] ::xounit::TestCase
        my assertEquals [ $sub test ] testError
        my assertEquals [ lindex [ split [ $sub error ] "\n" ] 0 ] 3
        my assertEquals [ lindex [ split [ $sub message ] "\n" ] 0 ] 3
        my debug [ $sub error ] 
    
}

testFailure

Description:
 
Code:
  ::xounit::test::TestTestCase instproc testFailure {}  {
   

        set testCase [ ::xounit::TestCase new A ]

        $testCase proc testFailure { } {

            my fail 2
        }

        set result [ $testCase runAlone ]

        my assertFalse [ $result passed ]
        set sub [ $result results ]

        my assertEquals [ $result name ] ::xounit::TestCase
        my assertEquals [ $sub name ] ::xounit::TestCase
        my assertEquals [ $sub test ] testFailure
        my assertEquals [ $sub error ] 2
        my assertEquals [ $sub message ] 2
    
}

testPass

Description:
 
Code:
  ::xounit::test::TestTestCase instproc testPass {}  {
   

        set testCase [ ::xounit::TestCase new A ]

        $testCase proc testPass { } {

            return 1
        }

        set result [ $testCase runAlone ]

        my assert [ $result passed ]
        set sub [ $result results ]

        my assertEquals [ $result name ] ::xounit::TestCase
        my assertEquals [ $sub name ] ::xounit::TestCase
        my assertEquals [ $sub test ] testPass
        my assertEquals [ $sub return ] 1
        my assertEquals [ $sub message ] 1
    
}

testReturnValue

Description:
 
Code:
  ::xounit::test::TestTestCase instproc testReturnValue {}  {
   

        return 5
    
}

testTestCase

Description:
 
Code:
  ::xounit::test::TestTestCase instproc testTestCase {}  {
   

        my assert [ expr [ my aTestVariable ] == 5 ] { Should be 5 }
    
}

testtestReturnValue

Description:
 
Code:
  ::xounit::test::TestTestCase instproc testtestReturnValue {}  {
   

        my assertEquals 5 [ my testReturnValue ]
    
}