-
Notifications
You must be signed in to change notification settings - Fork 201
Getting Started
Lars Fosdal edited this page Mar 25, 2014
·
10 revisions
This assumes you have already installed the DUnitX Wizard from the DUnitX source code.
You need a test project, and one or more test units.
From File|New|Other, select Delphi Projects and DUnitX Project
From File|New|Other, select Delphi Projects|Delphi Files and DUnitX 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.