Blue
Red
Green
Orange
Voilet
Slate
Dark

有哪些朋友在使用"测试驱动开发"技术,进来交流.(顶者有分)(200分)

  • 主题发起人 duhai_lee
  • 开始时间
D

duhai_lee

Unregistered / Unconfirmed
GUEST, unregistred user!
最近在看有关"敏捷开发"和"测试驱动开发"方面的东西, 也在着手实践. 不知道敏捷开发,在国内到底推行到什么程度了, 有多少公司在采用, 又有多少开发者在使用? 希望有这方面经验的朋友进来交流.
我一直在用delphi, 现在delphi下实践, 看有关例子,似乎不是很难, 但是毕竟没有把这些用在项目上的经验. 我在看David Astel著的<test-Driven development>(测试驱动开发).
里面主要以java为示范语言. 里面没有介绍Dunit. 看了前面几章,感觉很好.
欢迎大家踊跃发言, 共同学习,一起提高.
 
D

duhai_lee

Unregistered / Unconfirmed
GUEST, unregistred user!
大侠们 顶一下嘛 . .. ..
 
H

hzm7512

Unregistered / Unconfirmed
GUEST, unregistred user!
路过,学习
 
W

WUSUBAR

Unregistered / Unconfirmed
GUEST, unregistred user!
感兴趣 虔诚学习!!!
 

王思佳

Unregistered / Unconfirmed
GUEST, unregistred user!
多多指教!
 
G

gameboyda

Unregistered / Unconfirmed
GUEST, unregistred user!
我有同学是用C写驱动的,呵呵。不过我是做D的。
 
X

xfz8124

Unregistered / Unconfirmed
GUEST, unregistred user!
TDD还是很实用的,只不过感觉TDD对开发者的素养要求比较全面,Story的设计,用例的编码,都很有文章,当然更重要的是思维方式要适应才行
 
B

Beyondbill

Unregistered / Unconfirmed
GUEST, unregistred user!
在Delphi 下你用DUNIT同样可以做“测试驱动开发”技术的
 
X

xfz8124

Unregistered / Unconfirmed
GUEST, unregistred user!
当然我用的是DUnit,java不熟,语法都看的吃力
 

空心

Unregistered / Unconfirmed
GUEST, unregistred user!
比较感兴趣,那里有这方面的资料下载喔
 
D

duhai_lee

Unregistered / Unconfirmed
GUEST, unregistred user!
哈哈, 终于有人讨论了. 谢谢各位踊跃发言.对于界面测试,各位有什么高见嘛?
 
X

xfz8124

Unregistered / Unconfirmed
GUEST, unregistred user!
界面根本不值得测试,直接测试界面下面的机制就行了
 
X

xfz8124

Unregistered / Unconfirmed
GUEST, unregistred user!
unit TestUnit_OmrSp;
{Athor:月夜风筝 QQ:= 14574256 EMail:= 14574256@163.com
}
{
Delphi DUnit Test Case
----------------------
This unit contains a skeleton test case class generated by the Test Case Wizard.
Modify the generated code to correctly setup and call the methods from the unit
being tested.
}
interface
uses
TestFramework, Classes, Unit_OmrSp, Unit_VOmrSp, Windows, Unit_HBase, Forms, SysUtils;
type
// Test methods for class TOMR
TestTOMR = class(TTestCase)
strict private
FOMR: TOMR;
MEventMsgS: TStringList;
procedure CatOnError(ErrID, ErrDesc: string);
//捕捉事件
procedure CatOnFinished();
//捕捉事件
procedure CatOnOneReadOK(ReadString: string);
//捕捉事件
public
procedure SetUp;
override;
procedure TearDown;
override;
published
procedure TestValidateFomFile;
procedure TestRead_NoLib;
procedure TestRead_InValidLib;
procedure TestRead_UnSetFomFile;
procedure TestRead_OnLinePassedZero;
procedure TestRead_OnLinePassedNormal_50TFomFile;
procedure TestRead_OnLineContinousRead50TFom;
procedure TestReadSerialNo_OnLine;
procedure TestRead_OffLine;
procedure TestCharDeCode;
procedure TestStringDeCode;
procedure TestEncode;
end;

implementation
procedure TestTOMR.SetUp;
begin
FOMR := TOMR.Create(nil);
FOMR.LibPath:= 'In';
FOMR.OnError:= CatOnError;
FOmr.OnFinished:= CatOnFinished;
Fomr.OnOneReadOK:= CatOnOneReadOK;
MEventMsgS:= TStringList.Create;
end;

procedure TestTOMR.TearDown;
begin
FOMR.Free;
FOMR := nil;
MEventMsgS.Free;
end;

procedure TestTOMR.TestValidateFomFile;
var
ReturnValue: Boolean;
AFileName: string;
begin

AFileName:= ExtractFileDir(ParamStr(0)) + '/in/万方汇博--50题.fom';
ReturnValue := FOMR.ValidateFomFile(AFileName);
if not ReturnValue then
Fail('EspF: 语法正确的卡格式返回 True !');
AFileName:= ExtractFileDir(ParamStr(0)) + '/in/万方汇博--50题(错误改).fom';
ReturnValue := FOMR.ValidateFomFile(AFileName);
if ReturnValue then
Fail('EspF: 语法不正确的卡格式返回 False !');
end;

procedure TestTOMR.TestRead_NoLib;
var
Ret: Boolean;
begin
if FileExists(ExtractFilePath(ParamStr(0)) + 'omr.dll') then
RenameFile(ExtractFilePath(ParamStr(0)) + 'omr.dll', ExtractFilePath(ParamStr(0)) + 'omr.dll.bak');
FOMR.LibPath:= '';
FOMR.SetFomFile(ExtractFileDir(ParamStr(0)) + '/in/万方汇博--50题.fom');
FOMR.Read;
if FileExists(ExtractFilePath(ParamStr(0)) + 'omr.dll.bak') then
RenameFile(ExtractFilePath(ParamStr(0)) + 'omr.dll.bak', ExtractFilePath(ParamStr(0)) + 'omr.dll');
if FOMR.DevStatus <> dsUnInited then
Fail('EspF:动态库不存在时设备状态保持在UnInited状态!');
Ret:= (pos('[OnError]', MEventMsgS.Text) > 0 ) and (MEventMsgS.Count = 2) and (Pos('OMR01', MEventMsgS.Text) > 0);
if not Ret then
Fail('EspF:动态库不存在时触发OnError中的无库错!'#13 + 'Event Msg:' + MEventMsgS.Text);
end;

procedure TestTOMR.TestRead_InValidLib;
var
Ret: Boolean;
begin
RenameFile(ExtractFilePath(ParamStr(0)) + 'in/omr.dll', ExtractFilePath(ParamStr(0)) + 'in/omr.dll.bak');
RenameFile(ExtractFilePath(ParamStr(0)) + 'in/Invalid_OMR.DLL', ExtractFilePath(ParamStr(0)) + 'in/omr.dll');
FOMR.SetFomFile(ExtractFileDir(ParamStr(0)) + '/in/万方汇博--50题.fom');
RenameFile(ExtractFilePath(ParamStr(0)) + 'in/omr.dll', ExtractFilePath(ParamStr(0)) + 'in/Invalid_OMR.DLL');
RenameFile(ExtractFilePath(ParamStr(0)) + 'in/omr.dll.bak', ExtractFilePath(ParamStr(0)) + 'in/omr.dll');
if FOMR.DevStatus <> dsUnInited then
Fail('EspF:动态库失效时设备状态保持在UnInited状态!'#13 + 'Event Msg:' + MEventMsgS.Text);
Ret:= (pos('[OnError]', MEventMsgS.Text) > 0 ) and (MEventMsgS.Count = 1) and (Pos('OMR02', MEventMsgS.Text) > 0);
if not Ret then
Fail('EspF:动态库失效时触发OnError中的无效库错!'#13 + 'Event Msg:' + MEventMsgS.Text);
end;

procedure TestTOMR.TestRead_UnSetFomFile;
var
Ret: Boolean;
begin
FOMR.Read;
Ret:= (pos('[OnError]', MEventMsgS.Text) > 0 ) and (MEventMsgS.Count = 1) and (Pos('OMR04', MEventMsgS.Text) > 0);
if not Ret then
Fail('EspF:未设格式读卡,触发OnError中的未设置格式文件错!'#13 + 'Event Msg:' + MEventMsgS.Text);
end;

procedure TestTOMR.TestRead_OnLinePassedZero;
var
Ret: Boolean;
begin
FOMR.ContinuousRead:= False;
FOMR.SetFomFile(ExtractFileDir(ParamStr(0)) + '/in/万方汇博--50题.fom');
FOMR.Read;
Ret:= (Pos('[OnError]', MEventMsgS.Text) > 0) and (Pos('DEV16', MEventMsgS.Text) > 0) and (MEventMsgS.Count = 1);
{这里应能捕捉到OnError事件,并且是其中的无纸错}
if not Ret then
Fail('EspF:阅读机试图走纸但没有过卡触发OnError事件中的无纸错!' + #13 + '本测试需要纸进纸仓无纸的情况下进行!'#13 + 'Event Msg:' + MEventMsgS.Text);
end;

procedure TestTOMR.TestRead_OnLinePassedNormal_50TFomFile;
var
Ret: Boolean;
begin
FOMR.ContinuousRead:= False;
FOMR.SetFomFile(ExtractFileDir(ParamStr(0)) + '/in/万方汇博--50题.fom');
FOMR.Read;
Ret:= Pos('[OnOneReadOK]', MEventMsgS.Text) > 0;
{这里应能捕捉到OnReadOK事件}
if not Ret then
Fail('EspF:正常走纸解发OnOneReadOK事件!'+#13+'说明:请放50题卡一张'#13 + 'Event Msg:' + MEventMsgS.Text);
end;

procedure TestTOMR.TestRead_OnLineContinousRead50TFom;
var
Ret: Boolean;
begin
FOMR.ContinuousRead:= True;
FOMR.SetFomFile(ExtractFileDir(ParamStr(0)) + '/in/万方汇博--50题.fom');
FOMR.Read;
Ret:= (Pos('[OnOneReadOK]', MEventMsgS.Text) > 0) and (MEventMsgS.Count >= 2) and (Pos('[OnFinished]', MEventMsgS.Text) > 0);
if not Ret then
Fail('EspF:连续读卡完成时触发OnFinished事件!'#13 + '说明:请放一第或多张50题卡'#13 + 'Event Msg:' + MEventMsgS.Text);
end;

procedure TestTOMR.TestRead_OffLine;
var
AFileName: string;
Ret: Boolean;
begin
AFileName:= ExtractFileDir(ParamStr(0)) + '/in/万方汇博--50题.fom';
FOMR.SetFomFile(AFileName);
Ret:= (Pos('[OnError]', MEventMsgS.Text) > 0) and (Pos('OMR03', MEventMsgS.Text) > 0) and (MEventMsgS.Count = 1);
if not Ret then
Fail('EspF:联机失败触发OnError中联机错!' + #13 + '说明:本测试需要在未联机状态执行有效!'#13 + 'Event Msg:' + MEventMsgS.Text);
end;

procedure TestTOMR.TestReadSerialNo_OnLine;
{用例:读序列号
}
var
ReturnValue: string;
begin
ReturnValue := FOMR.ReadSerialNo;
// TODO: Validate method results
if Length(ReturnValue) <> 8 then
Fail('测试失败!');
end;

procedure TestTOMR.TestCharDeCode;
{用例:字解码
}
var
ReturnValue: string;
ErrorDecode: string;
BlankDecode: string;
ACh: Char;
begin
ACh:= 'H';
ErrorDecode:= '>';
BlankDecode:= '#';
// TODO: Setup method call parameters
ReturnValue := FOMR.CharDeCode(ACh, BlankDecode, ErrorDecode);
// TODO: Validate method results
if ReturnValue <> 'AB' then
Fail('测试失败!');
ACh:= #0;
ReturnValue := FOMR.CharDeCode(ACh, BlankDecode, ErrorDecode);
if ReturnValue <> '>' then
Fail('测试失败!');
end;

procedure TestTOMR.TestStringDeCode;
{用例:串解码
}
var
ReturnValue: string;
ErrorDecode: string;
BlankDecode: string;
SeparatStr: string;
AStr: string;
begin
AStr:= 'ABCO';
ErrorDecode:= '>';
BlankDecode:= '#';
SeparatStr:= ',';
// TODO: Setup method call parameters
ReturnValue := FOMR.StringDeCode(AStr, SeparatStr, BlankDecode, ErrorDecode);
// TODO: Validate method results
if ReturnValue <> 'A,B,C,ABCD' then
Fail('测试失败!');
AStr:= '';
ReturnValue:= FOMR.StringDeCode(AStr, SeparatStr, BlankDecode, ErrorDecode);
if ReturnValue <> '' then
Fail('测试失败!');
end;

procedure TestTOMR.TestEncode;
{用例:词编码
}
var
ReturnValue: string;
ErrorEncode: string;
Input: string;
begin
// TODO: Setup method call parameters
ErrorEncode:= '>';
FOMR.DeCodeMethod:= OMRCode;
Input:= ' ';
ReturnValue := FOMR.Encode(Input, ErrorEncode);
if ReturnValue <> '.' then
Fail('测试失败!');
// TODO: Validate method results
Input:= '';
ReturnValue := FOMR.Encode(Input, ErrorEncode);
if ReturnValue <> '>' then
Fail('测试失败!');
Input:= 'ABC';
ReturnValue := FOMR.Encode(Input, ErrorEncode);
if ReturnValue <> 'G' then
Fail('测试失败!');
FOMR.DeCodeMethod:= GBCode;
Input:= 'BCD';
ReturnValue := FOMR.Encode(Input, ErrorEncode);
if ReturnValue <> 'N' then
Fail('测试失败!');
Input:= ' ';
ReturnValue := FOMR.Encode(Input, ErrorEncode);
if ReturnValue <> 'P' then
Fail('测试失败!');
Input:= '';
ReturnValue := FOMR.Encode(Input, ErrorEncode);
if ReturnValue <> '>' then
Fail('测试失败!');
FOMR.DeCodeMethod:= DRSCode;
Input:= '';
ReturnValue := FOMR.Encode(Input, ErrorEncode);
if ReturnValue <> '>' then
Fail('测试失败!');
Input:= ' ';
ReturnValue := FOMR.Encode(Input, ErrorEncode);
if ReturnValue <> '*' then
Fail('测试失败!');
Input:= 'AB';
ReturnValue := FOMR.Encode(Input, ErrorEncode);
if ReturnValue <> 'C' then
Fail('测试失败!');
end;

procedure TestTOMR.CatOnError(ErrID, ErrDesc: string);
//捕捉事件
begin
MEventMsgS.Add(Format('[OnError] Param1 = %S, Param2 = %S' ,[ErrID, ErrDesc]));
end;

procedure TestTOMR.CatOnFinished();
//捕捉事件
begin
MEventMsgS.Add(Format('[OnFinished]' ,[]));
end;

procedure TestTOMR.CatOnOneReadOK(ReadString: string);
//捕捉事件
begin
MEventMsgS.Add(Format('[OnOneReadOK] Param1 = %S' ,[ReadString]));
end;

initialization
// Register any test cases with the test runner
RegisterTest(TestTOMR.Suite);
end.
 
X

xfz8124

Unregistered / Unconfirmed
GUEST, unregistred user!
MyQQ.Num:= 14574256
MyEMail:= MyQQ.Num + '@163.com';
Me.Welcome(AnyOne, 'Who Has TDD Experience');
if You.Ask('TDD') then
MakeSure(You.HasExperience) and Question.IsValueAble
else
Me.PayNoAttentionTo([You, You.Question]);
醉爱Delphi!
http://www.delphibbs.com/delphibbs/dispu.asp?username=xfz8124
 
D

duhai_lee

Unregistered / Unconfirmed
GUEST, unregistred user!
谢谢8124。 加您为好友了。
 
L

LL_11

Unregistered / Unconfirmed
GUEST, unregistred user!
路过,学习
 

冲浪

Unregistered / Unconfirmed
GUEST, unregistred user!
我决得这个网址大全很实用的,请大家多多支持
http://16311.855.com
 
L

lhdqz

Unregistered / Unconfirmed
GUEST, unregistred user!
听说并非软件全能用
 

六小灵通

Unregistered / Unconfirmed
GUEST, unregistred user!
路过 学习
 
D

duhai_lee

Unregistered / Unconfirmed
GUEST, unregistred user!
接受答案了.
 

Similar threads

D
回复
0
查看
2K
DelphiTeacher的专栏
D
D
回复
0
查看
2K
DelphiTeacher的专栏
D
D
回复
0
查看
1K
DelphiTeacher的专栏
D
D
回复
0
查看
2K
DelphiTeacher的专栏
D
D
回复
0
查看
873
DelphiTeacher的专栏
D
顶部 底部