#ATestContainer C 'This abstract class identifies TestContainer classes. TestContainers are a 'classes that hold different test case methods. Name r s CaseNames p String[] Result p TestResult 'The current test case R p TestResult 'The current test case Debug p b _new m [(ShowDebug)b] RunCase m (oCase)ITestCase;(oTestResult)TestResult; SetupEach m TearDownEach m SetupContainer m TearDownContainer m #ITest C Run m (Result)TestResult;[(ShowDebug)b] CountTestCases m i #ITestCase ITest C Name r s Container r ATestContainer #TestCase ITestCase C 'The TestCase class is responsible for executing a specific test case. 'The test case to be executed is specified through the Name and TestContainer 'properties in the class. The Run method will call the appropriate Setup 'and TearDown methods for the test case as well as executing the test case 'method itself. Name r s 'Name of the test case Container r ATestContainer 'Reference to the test container containing the test method to be executed. _new m (sName)s(oTestContainer)ATestContainer; 'Initializes the TestCase. Used in lieu of a constructor. Run m (oTestResult)TestResult;[(ShowDebug)b] CountTestCases m i #TestError C TestCase p ITestCase 'Sets a reference to the test case where the error/failure was generated Description p s ErrNumber p l 'Set the error number (used by test errors, not failures) Source p s #TestErrors C 'The TestErrors class is the collection class for TestError objects. 'It holds the test case failures and errors that have been collected 'by the TestResult object. Items r TestError[] _new m 'Initialize variables Add m TestError (oTestCase)ITestCase;(lNumber)l(sSource)s(sDescription)s 'Add a new error or failure to the error collection. Count r l 'Return a TestError object from the collection by index - one-based 'Return number of TestError objects in the collection. #TestParameter C Name p s Value p v Parameters p TestParameters #TestParameters C _new m AddParameter m (oParameter)TestParameter; Add m TestParameter (sName)s(vValue)v Count m l Item m TestParameter (vIndex)v #TestResult C 'The TestResult object collects the results from executing test cases. It is an 'instance of the Collecting Parameter pattern. When new failures or errors 'are added to the TestResult or if a test case is started or finished, the 'TestResult generates events to notify its event handlers about what has happened. CountRunnedTests r i 'Gets the number of run tests. Failures r TestErrors 'Returns a collection of failures Errors r TestErrors 'Returns a collection of errors Parameters p TestParameters 'Set and Returns parameter collection :AfterStartTest : (oTestCase)ITestCase; 'Events :AfterEndTest : :AfterAddError : (oError)TestError; :AfterAddFailure : (oError)TestError; :AfterAddTrace : (sMessage)s _new m 'Initialize Variables WasSuccessful r b 'Returns whether the entire test was successful or not. StartTest m (oTestCase)ITestCase; 'Informs the result that a test will be started. EndTest m 'Informs the result that a test is completed. AddFailure m (sDescription)s 'Adds a failure to the collection of failures. AddError m (lNumber)l(sSource)s(sDescription)s 'Adds a error to the collection of errors. AddTrace m (sMessage)s 'Add trace message Assert m (bCondition)b[(sMessage)s] 'Asserts that a condition is true. If it isn't it raises a failure with the given message. 'bCondition: condition to be asserted 'sMessage: optional message describing the asserted condition AssertFalse m (bCondition)b[(sMessage)s] 'Asserts that a condition is false. If it isn't it raises a failure with the given message. 'bCondition: condition to be asserted 'sMessage: optional message describing the asserted condition AssertEqualsString m (sExpected)s(sActual)s[(sMessage)s] 'Asserts that the expected string equals the actual string. 'sExpected: the expected value 'sActual: the actual value 'sMessage: optional message describing the asserted condition AssertEqualsLong m (lExpected)l(lActual)l[(sMessage)s] 'Asserts that the expected long value equals the actual long value. 'lExpected: the expected value 'lActual: the actual value 'sMessage: optional message describing the asserted condition AssertEqualsFloat m (dExpected)f(dActual)f(dDelta)f[(sMessage)s] 'Asserts that the expected Float value equals the actual Float value with delta precision. 'dExpected: the expected value 'dActual: the actual value 'dDelta: tolerated precision 'sMessage: optional message describing the asserted condition AssertEqualsVariant m (vExpected)v(vActual)v[(sMessage)s] 'Asserts that the expected variant equals the actual variant. 'vExpected: the expected value 'vActual: the actual value 'sMessage: optional message describing the asserted condition AssertExists m (oObject)o[(sMessage)s] 'Asserts that an object is not nothing 'oObject: object reference 'sMessage: the detail message to record if this assertion fails AssertEqualsObject m (oExpected)o(oActual)o[(sMessage)s] 'Asserts that the expected object equals the actual object. 'oExpected: expected object reference 'oActual: actual object reference 'sMessage: the detail message to record if this assertion fails AssertNotEmpty m (vVariant)v[(sMessage)s] 'Asserts that a variant is not empty 'vVariant: variant to evaluate 'sMessage: the detail message to record if this assertion fails AssertEmpty m (vVariant)v[(sMessage)s] 'Asserts that a variant is empty 'vVariant: variant to evaluate 'sMessage: the detail message to record if this assertion fails AssertNotNull m (vVariant)v[(sMessage)s] 'Asserts that a variant is not null 'vVariant: variant to evaluate 'sMessage: the detail message to record if this assertion fails AssertError m (ErrorNumber)l(ErrorMessage)s[(ErrorNumberExpected)l(StrMessage)s] 'Asserts that an error was thrown 'Use it so: 'Try DosomethingThatThrowserror() 'AssertError(Error.Code, Error.Text) #TestSuite ITest C 'The TestSuite class represents a suite of different tests to be run. The TestSuite contains 'a part-whole hierarchy of objects that implement the ITest interface -- 'including TestCase objects and other TestSuite objects. Executing the Run method for the 'TestSuite will execute all test cases that it contains. The TestSuite class also provides 'methods for add all test cases contained in a test container object into the suite. Tests r ITest[] _new m Run m (oTestResult)TestResult;[(ShowDebug)b] 'Runs all tests contained within the collection and collects the result in the TestResult parameter. CountTestCases m i 'Number of test cases contained in the suite AddTest m (oTest)ITest; 'Add a object implementing ITest (either a TestCase or TestSuite) to the suite. AddTestCase m (oTestCase)ITestCase; 'Add a TestCase to the suite. AddNewTestCase m (sName)s(oTestContainer)ATestContainer; 'Create a new test case and add it to the suite. AddAllTestCases m (oTestContainer)ATestContainer; 'Create all test cases that are contained in the specified TestContainer and add them to the suite. #UnitTest C Suite p TestSuite DoSelfTest p b 'Normal name for testclasses starts with _GuTest, here it can be redefined _new m ShowTestForm m 'Show the Test Runner Form Test m [(ContainerName)s(CaseName)s(ShowDebug)b] 'Runs the Unittest and prints the result to the console. Optional limited to one testclass and/or one testmethod. _RunTests m (Result)TestResult;[(ContainerName)s(CaseName)s(ShowDebug)b(DoSelfTest)b] 'Run all tests, optional limited by Container or TestCaseName. TestResult contains . _PrintResult m (Res)TestResult; 'Prints a result. GetAllTestContainerNames M String[] [(DoSelfTest)b] #_TestAllAsserts ATestContainer C constDegUnittestSelftest C b T TestAssert m TestAssertEmpty m TestAssertEqualsFloat m TestAssertEqualsLong m TestAssertEqualsObject m TestAssertEqualsString m TestAssertEqualsVariant m TestAssertError m TestAssertExists m TestAssertFalse m TestAssertNotEmpty m TestAssertNotNull m #_TestErrorsAndFailures ATestContainer C constDegUnittestSelftest C b T TestStringFailure m TestLongFailure m TestAddError m TestAddTrace m #_TestExample1 ATestContainer C constDegUnittestSelftest C b T SetupEach m TeardownEach m TestStringNull m TestStringOk m #_TestExample2 ATestContainer C constDegUnittestSelftest C b T SetupContainer m TeardownContainer m SetupEach m TeardownEach m TestFirstTest m TestThirdTest m TestSecondTest m #_TestIntentionalError ATestContainer C constDegUnittestSelftest C b T TestError m