* Add inherited to setup/teardown

git-svn-id: trunk@22406 -
This commit is contained in:
michael 2012-09-16 15:59:21 +00:00
parent fcb3d0c256
commit 76b9b4fdac

View File

@ -86,7 +86,7 @@ Type
// Create implementation of test code. After 'Implementation' keyword was added // Create implementation of test code. After 'Implementation' keyword was added
procedure CreateImplementationCode(C: TStrings); virtual; procedure CreateImplementationCode(C: TStrings); virtual;
// Add a test method body to the implementation. AddFail=True adds a Fail statement. // Add a test method body to the implementation. AddFail=True adds a Fail statement.
procedure AddMethodImpl(C: TStrings; Const AClassName, AMethodName: String; AddFail: Boolean);virtual; procedure AddMethodImpl(C: TStrings; Const AClassName, AMethodName: String; AddFail: Boolean; AddInherited : Boolean = false);virtual;
// Called when all the methods of a class have been emitted. Empty. // Called when all the methods of a class have been emitted. Empty.
procedure EndTestClassImpl(C: TStrings; Const AClassName: String);virtual; procedure EndTestClassImpl(C: TStrings; Const AClassName: String);virtual;
// Create interface test code. After uses clause of interface section. // Create interface test code. After uses clause of interface section.
@ -510,7 +510,7 @@ begin
EndTestClassDecl(C,CN); EndTestClassDecl(C,CN);
end; end;
procedure TFPTestCodeCreator.AddMethodImpl(C : TStrings; Const AClassName,AMethodName : String; AddFail : Boolean); procedure TFPTestCodeCreator.AddMethodImpl(C : TStrings; Const AClassName,AMethodName : String; AddFail : Boolean; AddInherited : Boolean = false);
begin begin
C.Add(''); C.Add('');
@ -519,6 +519,8 @@ begin
C.Add('begin'); C.Add('begin');
if AddFail then if AddFail then
C.Add(Format(' Fail(''%s'');',[FM])); C.Add(Format(' Fail(''%s'');',[FM]));
if AddInherited then
C.Add(' Inherited;');
C.Add('end;'); C.Add('end;');
C.Add(''); C.Add('');
end; end;
@ -530,9 +532,9 @@ begin
C.Add(' { '+AClassName+' }'); C.Add(' { '+AClassName+' }');
C.Add(''); C.Add('');
if coSetup in CodeOptions then if coSetup in CodeOptions then
AddMethodImpl(C,AClassName,'Setup',False); AddMethodImpl(C,AClassName,'Setup',False,True);
if coTearDown in CodeOptions then if coTearDown in CodeOptions then
AddMethodImpl(C,AClassName,'TearDown',False); AddMethodImpl(C,AClassName,'TearDown',False,True);
end; end;
procedure TFPTestCodeCreator.EndTestClassImpl(C : TStrings; Const AClassName : String); procedure TFPTestCodeCreator.EndTestClassImpl(C : TStrings; Const AClassName : String);