Getting Started - VSoftTechnologies/DUnitX GitHub Wiki
This assumes you have already installed the DUnitX Wizard from the DUnitX source code.
Creating your first test
You need a test project, and one or more test units.
Creating a test project
From File|New|Other, select Delphi Projects and DUnitX Project
Adding a test unit
From File|New|Other, select Delphi Projects|Delphi Files and DUnitX Unit
Understanding the test unit
DUnitX uses Attributes and RTTI to identify and instrument a test. A TestFixture identifies your test object. Each test object needs Setup and Teardown methods, as well as Test methods with TestCase specifications. It can also have SetupFixture and TeardownFixture methods, which (Needs editing)
unit Unit1;
interface
uses
DUnitX.TestFramework;
type
[TestFixture]
TMyTestObject = class(TObject)
public
[Setup]
procedure Setup;
[TearDown]
procedure TearDown;
// Sample Methods
// Simple single Test
[Test]
procedure Test1;
// Test with TestCase Atribute to supply parameters.
[Test]
[TestCase('TestA','1,2')]
[TestCase('TestB','3,4')]
procedure Test2(const AValue1 : Integer;const AValue2 : Integer);
end;
implementation
Each test fixture should be registered in the init section of the unit.
initialization
TDUnitX.RegisterTestFixture(TMyTestObject);
end.