Changeset 8 for trunk/UTest.pas


Ignore:
Timestamp:
Aug 20, 2022, 8:22:00 AM (2 years ago)
Author:
chronos
Message:
  • Added: Update multiple test.
  • Modified: Simplified tests structure.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UTest.pas

    r7 r8  
    44
    55uses
    6   Classes, SysUtils, USubversion, FileUtil, Generics.Collections;
     6  Classes, SysUtils, FileUtil, Generics.Collections;
    77
    88type
     
    1616    TestResult: TTestResult;
    1717    Log: string;
     18    procedure Initialize; virtual;
    1819    procedure Run; virtual;
     20    procedure Finalize; virtual;
    1921    procedure Evaluate(Passed: Boolean);
    2022    procedure Pass;
     
    3234  end;
    3335
    34   { TTestCaseSvn }
    35 
    36   TTestCaseSvn = class(TTestCase)
    37   private
    38     Subversion: TExecute;
    39     SubversionAdmin: TSubversionAdmin;
    40     function CheckError(Text: string): Boolean;
    41   protected
    42     RepoDir: string;
    43     WorkDir: string;
    44     TestDir: string;
    45     procedure Svn(Parameters: array of string);
    46     procedure SvnAdmin(Parameters: array of string);
    47   public
    48     procedure Run; override;
    49     constructor Create; override;
    50     destructor Destroy; override;
    51   end;
    5236
    5337resourcestring
     
    6448
    6549implementation
    66 
    67 uses
    68   USvnZero;
    6950
    7051procedure Translate;
     
    9172{ TTestCase }
    9273
     74procedure TTestCase.Initialize;
     75begin
     76end;
     77
    9378procedure TTestCase.Run;
     79begin
     80end;
     81
     82procedure TTestCase.Finalize;
    9483begin
    9584end;
     
    129118  Passed: Integer;
    130119  Failed: Integer;
    131   LastDir: string;
    132120begin
    133121  for I := 0 to Count - 1 do
    134122  with Items[I] do begin
    135123    WriteLn('== ' + Name + ' ======= ');
    136     LastDir := GetCurrentDir;
     124    Initialize;
    137125    Run;
    138     ChDir(LastDir);
     126    Finalize;
    139127  end;
    140128
     
    151139end;
    152140
    153 { TTestCaseSvn }
    154 
    155 procedure TTestCaseSvn.Svn(Parameters: array of string);
    156 begin
    157   Subversion.ExecuteOutput(Parameters);
    158   if CheckError(Subversion.ErrorOutput) then
    159     TestResult := trFailed;
    160 end;
    161 
    162 procedure TTestCaseSvn.SvnAdmin(Parameters: array of string);
    163 begin
    164   SubversionAdmin.ExecuteOutput(Parameters);
    165   if CheckError(SubversionAdmin.ErrorOutput) then
    166     TestResult := trFailed;
    167 end;
    168 
    169 function TTestCaseSvn.CheckError(Text: string): Boolean;
    170 begin
    171   Result := Pos('svn: E', Text) > 0;
    172 end;
    173 
    174 procedure TTestCaseSvn.Run;
    175 begin
    176   ChDir(TestDir);
    177 end;
    178 
    179 constructor TTestCaseSvn.Create;
    180 begin
    181   TestDir := GetTempDir(False) + 'SVNZero';
    182   ForceDirectories(TestDir);
    183   RepoDir := TestDir + DirectorySeparator + 'Repo';
    184   WorkDir := TestDir + DirectorySeparator + 'Work';
    185   //Subversion := TSubversion.Create;
    186   Subversion := TSvnZero.Create;
    187   SubversionAdmin := TSubversionAdmin.Create;
    188 end;
    189 
    190 destructor TTestCaseSvn.Destroy;
    191 begin
    192   FreeAndNil(SubversionAdmin);
    193   FreeAndNil(Subversion);
    194   inherited;
    195 end;
    196 
    197141end.
    198142
Note: See TracChangeset for help on using the changeset viewer.