' Gambas class file ''' 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. Inherits ITestCase '' Member variables Private $Name As String Private $MyContainer As ATestContainer Private $Debug As Boolean '' Name of the test case Property Read Name As String '' Reference to the test container containing the test method to be executed. Property Read Container As ATestContainer '' Initializes the TestCase. Used in lieu of a constructor. Public Sub _new(sName As String, oTestContainer As ATestContainer) $Name = sName $MyContainer = oTestContainer End Sub ' '' Name of the test case ' Property Read Name As String '' Test container that the test case uses 'Property Read TestContainer As TestContainer Function Name_Read() As String Return $Name End 'Create the fixture, run the test and collect the results in TestResult Public Sub Run(oTestResult As TestResult, Optional ShowDebug As Boolean) $Debug = $MyContainer.Debug oTestResult.StartTest(Me) 'On Error Resume Next '' Set up test fixture Try $MyContainer.SetupEach '' Run test '' Check for exceptions if Setup or Test method If Error Then oTestResult.AddError(Error.Code, Error.Where & "::Setup", Error.Text) Error.Clear Else $MyContainer.RunCase(Me, oTestResult) End If '' Tear down test fixture '' must ensure that test fixture is properly torn down if any failures have occurred Try $MyContainer.TearDownEach If Error Then oTestResult.AddError(Error.Code, Error.Where & "::TearDown", error.Text) Error.Clear End If oTestResult.EndTest $MyContainer = Null Error.Clear End Sub Public Function CountTestCases() As Integer Return 1 End Function Private Function Container_Read() As ATestContainer Return $MyContainer End