소스 검색

* Make sure browsertestrunner & consoletestrunner share re-run functionality

michael 6 년 전
부모
커밋
7d13098123
3개의 변경된 파일26개의 추가작업 그리고 35개의 파일을 삭제
  1. 4 20
      packages/fpcunit/browsertestrunner.pas
  2. 3 15
      packages/fpcunit/consoletestrunner.pas
  3. 19 0
      packages/fpcunit/fpcunitreport.pas

+ 4 - 20
packages/fpcunit/browsertestrunner.pas

@@ -26,9 +26,7 @@ unit BrowserTestRunner;
 interface
 
 uses
-  CustApp, browserapp, Classes, SysUtils,
-  FPCUnit, TestRegistry,
-  FPCUnitReport, htmlTestReport;
+  CustApp, browserapp, Classes, SysUtils,  FPCUnit, TestRegistry,  FPCUnitReport, htmlTestReport;
 
 const
   Version = '0.9';
@@ -37,15 +35,6 @@ type
 
   { TRunForm }
 
-  TRunForm = class(TComponent)
-  private
-    FOnRun: TNotifyEvent;
-  Public
-    Procedure Initialize; virtual;
-    Property OnRun : TNotifyEvent Read FOnRun Write FOnRun;
-  end;
-  TRunFormClass = class of TRunForm;
-
   { TTestRunner }
 
   TTestRunner = class(TBrowserApplication)
@@ -88,13 +77,6 @@ type
     procedure EndTestSuite(ATestSuite: TTestSuite); override;
   end;
 
-{ TRunForm }
-
-procedure TRunForm.Initialize;
-begin
-  // Do nothing
-end;
-
 procedure TProgressWriter.WriteChar(c: char);
 begin
   write(c);
@@ -182,7 +164,9 @@ begin
     R:=RunFormClass.Create(Self);
     R.OnRun:=@DoRunAgain;
     R.Initialize;
-    end;
+    end
+  else
+    RunTests;
   Terminate;
 end;
 

+ 3 - 15
packages/fpcunit/consoletestrunner.pas

@@ -62,15 +62,6 @@ type
   { TTestRunner }
 
   { TRunForm }
-  // For compatibility with browser testrunner
-  TRunForm = class(TComponent)
-  private
-    FOnRun: TNotifyEvent;
-  Public
-    Procedure Initialize; virtual;
-    Property OnRun : TNotifyEvent Read FOnRun Write FOnRun;
-  end;
-  TRunFormClass = class of TRunForm;
 
   TTestRunner = class({$IFDEF NODEJS}TNodeJSApplication{$ELSE}TBrowserApplication {$ENDIF})
   private
@@ -421,11 +412,8 @@ begin
     DoTestRun(FLastTest);
 end;
 
-procedure TRunForm.Initialize;
-begin
-  // Do nothing
-end;
-
-
+initialization
+  DefaultFormat:=fplain;
+  DefaultRunAllTests:=True;
 end.
 

+ 19 - 0
packages/fpcunit/fpcunitreport.pas

@@ -152,6 +152,17 @@ type
     Property TestListener: ITestListener read FTestListener; // ToDo: replace when interfaces are implemented
   end;
 
+  // This is a callback which can be used to re-run test in apps
+  TRunForm = class(TComponent)
+  private
+    FOnRun: TNotifyEvent;
+  Public
+    Procedure Initialize; virtual;
+    Property OnRun : TNotifyEvent Read FOnRun Write FOnRun;
+  end;
+  TRunFormClass = class of TRunForm;
+
+
 implementation
 
 { TCustomResultsWriterTestListener }
@@ -405,5 +416,13 @@ begin
     Inc(TSuiteResults(FResultsList[i]).Ignores);
 end;
 
+
+{ TRunForm }
+
+procedure TRunForm.Initialize;
+begin
+  // Do nothing
+end;
+
 end.