|
||||||
SUMMARY: CHILDREN | PARAMETER | INSTPROC | INSTFILTER | INSTFORWARD | DETAIL: | INSTPROC |
::xotcl::Object | +--::xox::Node | +--::xounit::Test | +--::xounit::Assert | +--::xounit::TestCase
Variables | |||
Name | Default Value | Class | Comment |
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 | |
Name | Comment |
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 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 }
::xounit::test::TestTestCase instproc setUp {} { my aTestVariable 5 }
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.
::xounit::test::TestTestCase instproc tearDown {} { my unset aTestVariable my assertFalse [ my exists aTestVariable ] { Should have unset aTestVariable } }
::xounit::test::TestTestCase instproc test {} { set test [ ::xounit::TestCase new ] my assertEquals [ $test name ] ::xounit::TestCase #my assertEquals [ $test toString ] "" }
::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 ] }
::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 }
::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 }
::xounit::test::TestTestCase instproc testReturnValue {} { return 5 }
::xounit::test::TestTestCase instproc testTestCase {} { my assert [ expr [ my aTestVariable ] == 5 ] { Should be 5 } }
::xounit::test::TestTestCase instproc testtestReturnValue {} { my assertEquals 5 [ my testReturnValue ] }