???????дJ(rèn)ava???????????????????JUnit?????????????Delphi???????????Delphi??????????????DUnit??

????DUnit??XUnit?????е???????Extreme Programming???????Xtreme Testing?????????

????DUnit???÷???JUnit??????????????????????????????????DUnit?????????http://dunit.sourceforge.net/??????????http://sourceforge.net/projects/dunit/

??????DUnit????????????????????D:/Study/DelphiLib/??????Delphi 7????DUnit·?????? Tools- > Environment Options ????? Library -> Library Path??????DUnit?????????

????????????CnPack ??Delphi??????????????????? File -> New -> Other -> CnPack -> DUnit????????????? ?н????μ??????????

?????????????????????????????????AppFun?е? GetString() ?? Add() ??????

TAppFun.pas
(*
UTest by Jason
2010-01-06 21:30
*)
unit AppFun;
interface
uses SysUtils;
type TAppFun = class(TObject)
public
class function GetString(sName: string; iAge: Integer): string;
class function Add(iA: Integer; iB: Integer): Integer;
end;
implementation
class function TAppFun.GetString(sName: string; iAge: Integer): string;
begin
result := 'Hello ' + sName + '?? your age is ' +
IntToStr(iAge);
end;
class function TAppFun.Add(iA: Integer; iB: Integer): Integer;
begin
Result := iA + iB;
end;
end.
UTest.pas
(*
UTest by Jason
2010-01-06 21:30
*)
unit UTest;
interface
uses
Windows?? SysUtils?? Classes?? TestFramework?? TestExtensions;
type
TTest = class(TTestCase)
protected
procedure SetUp; override;
procedure TearDown; override;
published
procedure Test;
procedure TestGetString();
end;
implementation
uses
AppFun?? Dialogs;
procedure TTest.Setup;
begin
ShowMessage('In Setup!');
end;
procedure TTest.TearDown;
begin
ShowMessage('In TearDown!');
end;
procedure TTest.Test;
begin
Self.Check(TAppFun.GetString('Jason'?? 22) = 'Hello Jason?? your age is 22'??
'Second Test');
end;
procedure TTest.TestGetString();
begin
Check(TAppFun.Add(3?? 5) = 8?? 'First Test');
end;
initialization
TestFramework.RegisterTest(TTest.Suite);
end.