TTestCase Object Methods |
Unit
TestFramework
Declaration
TTestCase = class(TAbstractTest, ITest)
Description
To define a test case
1) implement a subclass of TestCase
2) define instance variables that store the state of the fixture
3) initialize the fixture state by overriding setUp
4) clean-up after a test by overriding tearDown.
Each test runs in its own fixture so there can be no side effects among test runs. Here is an example:
interface type TMathTest = class(TTestCase) private fValue1, fValue2: Float; procedure testAdd; public procedure setUp; override; end; implementation procedure TMathTest.setUp; begin fValue1 := 2.0; fValue2 := 3.0; end; |
procedure TMathTest.testAdd; var testResult: Float; begin testResult := fValue1 + fValue2; check(testResult = 5.0); end; |
Introduced Methods |
![]() | Check ![]() | Checks that a condition is met. |
![]() | CheckEquals ![]() | |
![]() | CheckNotEquals ![]() | |
![]() | CheckNotNull ![]() | |
![]() | CheckNull ![]() | |
![]() | CheckSame ![]() | |
![]() | Create ![]() | Create an instance of a test fixture to run the named test. |
![]() | EqualsErrorMessage | |
![]() | Fail ![]() | Report a test failure. |
![]() | FailEquals ![]() | |
![]() | FailNotEquals ![]() | |
![]() | FailNotSame ![]() | |
![]() | NotEqualsErrorMessage | |
![]() | NotSameErrorMessage | |
![]() | Run | |
![]() | RunBare ![]() | Runs the test case and collects the results in TestResult. |
![]() | RunTest ![]() | Perform the test. |
![]() | SetUp ![]() | Sets up the fixture, for example, open a network connection. |
![]() | StopTests ![]() | Stops testing. |
![]() | Suite ![]() | Create a test suite. |
![]() | TearDown ![]() | Tears down the fixture, for example, close a network connection. |
|