mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-12-16 04:30:35 +01:00
* Patch from Dean Zobec to add ability to skip tests
git-svn-id: trunk@3974 -
This commit is contained in:
parent
5f92ba07a6
commit
1e66422b82
@ -229,8 +229,10 @@ type
|
||||
FFailures: TFPList;
|
||||
FErrors: TFPList;
|
||||
FListeners: TFPList;
|
||||
FSkippedTests: TFPList;
|
||||
function GetNumErrors: integer;
|
||||
function GetNumFailures: integer;
|
||||
function GetNumSkipped: integer;
|
||||
public
|
||||
constructor Create; virtual;
|
||||
destructor Destroy; override;
|
||||
@ -246,12 +248,16 @@ type
|
||||
procedure Run(ATestCase: TTestCase);
|
||||
procedure RunProtected(ATestCase: TTest; protect: TProtect);
|
||||
function WasSuccessful: boolean;
|
||||
function SkipTest(ATestCase: TTestCase): boolean;
|
||||
procedure AddToSkipList(ATestCase: TTestCase);
|
||||
procedure RemoveFromSkipList(ATestCase: TTestCase);
|
||||
published
|
||||
property Failures: TFPList read FFailures;
|
||||
property Errors: TFPList read FErrors;
|
||||
property RunTests: integer read FRunTests;
|
||||
property NumberOfErrors: integer read GetNumErrors;
|
||||
property NumberOfFailures: integer read GetNumFailures;
|
||||
property NumberOfSkippedTests: integer read GetNumSkipped;
|
||||
end;
|
||||
|
||||
function ComparisonMsg(const aExpected: string; const aActual: string): string;
|
||||
@ -971,6 +977,7 @@ begin
|
||||
FFailures := TFPList.Create;
|
||||
FErrors := TFPList.Create;
|
||||
FListeners := TFPList.Create;
|
||||
FSkippedTests := TFPList.Create;
|
||||
end;
|
||||
|
||||
|
||||
@ -981,6 +988,7 @@ begin
|
||||
FreeObjects(FErrors);
|
||||
FErrors.Free;
|
||||
FListeners.Free;
|
||||
FSkippedTests.Free;
|
||||
end;
|
||||
|
||||
|
||||
@ -1005,6 +1013,12 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
function TTestResult.GetNumSkipped: integer;
|
||||
begin
|
||||
Result := FSkippedTests.Count;
|
||||
end;
|
||||
|
||||
|
||||
procedure TTestResult.AddListener(AListener: ITestListener);
|
||||
begin
|
||||
FListeners.Add(pointer(AListener));
|
||||
@ -1066,9 +1080,12 @@ end;
|
||||
|
||||
procedure TTestResult.Run(ATestCase: TTestCase);
|
||||
begin
|
||||
StartTest(ATestCase);
|
||||
RunProtected(ATestCase, @ProtectTest);
|
||||
EndTest(ATestCase);
|
||||
if not SkipTest(ATestCase) then
|
||||
begin
|
||||
StartTest(ATestCase);
|
||||
RunProtected(ATestCase, @ProtectTest);
|
||||
EndTest(ATestCase);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
@ -1117,5 +1134,37 @@ begin
|
||||
//unlock mutex
|
||||
end;
|
||||
|
||||
function TTestResult.SkipTest(ATestCase: TTestCase): Boolean;
|
||||
var
|
||||
i: integer;
|
||||
begin
|
||||
Result := false;
|
||||
if FSkippedTests.Count = 0 then
|
||||
begin
|
||||
result := false;
|
||||
Exit;
|
||||
end
|
||||
else
|
||||
for i := 0 to FSkippedTests.Count - 1 do
|
||||
begin
|
||||
if PtrInt(FSkippedTests[i]) = PtrInt(ATestCase) then
|
||||
begin
|
||||
Result := true;
|
||||
Exit;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
procedure TTestResult.AddToSkipList(ATestCase: TTestCase);
|
||||
begin
|
||||
FSkippedTests.Add(ATestCase);
|
||||
end;
|
||||
|
||||
procedure TTestResult.RemoveFromSkipList(ATestCase: TTestCase);
|
||||
begin
|
||||
FSkippedTests.Remove(ATestCase);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user