Browse Source

* Add inherited to setup/teardown

git-svn-id: trunk@22406 -
michael 13 years ago
parent
commit
76b9b4fdac
1 changed files with 6 additions and 4 deletions
  1. 6 4
      packages/fcl-passrc/src/pastounittest.pp

+ 6 - 4
packages/fcl-passrc/src/pastounittest.pp

@@ -86,7 +86,7 @@ Type
     // Create implementation of test code. After 'Implementation' keyword was added
     procedure CreateImplementationCode(C: TStrings); virtual;
     // 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.
     procedure EndTestClassImpl(C: TStrings; Const AClassName: String);virtual;
     // Create interface test code. After uses clause of interface section.
@@ -510,7 +510,7 @@ begin
     EndTestClassDecl(C,CN);
 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
   C.Add('');
@@ -519,6 +519,8 @@ begin
   C.Add('begin');
   if AddFail then
     C.Add(Format('  Fail(''%s'');',[FM]));
+  if AddInherited then
+    C.Add('  Inherited;');  
   C.Add('end;');
   C.Add('');
 end;
@@ -530,9 +532,9 @@ begin
   C.Add('  { '+AClassName+' }');
   C.Add('');
   if coSetup in CodeOptions then
-    AddMethodImpl(C,AClassName,'Setup',False);
+    AddMethodImpl(C,AClassName,'Setup',False,True);
   if coTearDown in CodeOptions then
-    AddMethodImpl(C,AClassName,'TearDown',False);
+    AddMethodImpl(C,AClassName,'TearDown',False,True);
 end;
 
 procedure TFPTestCodeCreator.EndTestClassImpl(C : TStrings; Const AClassName : String);