Created Oct, 2003, by Charlie Calvert, published under the MPL
This document provides a quickstart and very basic syntax reference for DUnit users.
DUnit provides a means for you to manually create tests that prove the validity of your code. You leave the code that you created alone, and create a new class that will test your code. The new class descends from a DUnit class called TTestCase. In that class, you will create a series of methods beginning with the word test. Each method that you create will test a part of your program. After you are done, you should have tests that "cover" your entire program.
Figure 1: A simple test case created with the syntax shown in this article.
Descend your test case from TTestCase, being sure to include TestFrameWork in your uses clause. The test methods you create should be published, take no paramters, and begin with the word test. Add code at the bottom of your unit in the initialization section to register your test.
unit DUnitMathTest;
interface
uses
TestFrameWork;
type
TTestMath = class (TTestCase)
published
procedure TestArcCos;
end;
implementation
procedure TestArcCos;
begin
Check(1=1);
end;
initialization
TestFramework.RegisterTest(TTest.Suite);
end.
Listing 1: The Application Source
program RunTest; uses DUnitMathTest, TestFrameWork, GuiTestRunner; begin GuiTestRunner.RunRegisteredTests; end.