mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-16 13:39:26 +02:00
+ add a simple test runner for FPCUnit (no parameters, only plain output, sets ExitCode depending on any failures/errors) that can be used with FPC's testsuite
git-svn-id: trunk@35095 -
This commit is contained in:
parent
9749ddc3bb
commit
933e449848
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -2400,6 +2400,7 @@ packages/fcl-fpcunit/src/fpmake.inc svneol=native#text/plain
|
|||||||
packages/fcl-fpcunit/src/fpmake.pp svneol=native#text/plain
|
packages/fcl-fpcunit/src/fpmake.pp svneol=native#text/plain
|
||||||
packages/fcl-fpcunit/src/latextestreport.pp svneol=native#text/plain
|
packages/fcl-fpcunit/src/latextestreport.pp svneol=native#text/plain
|
||||||
packages/fcl-fpcunit/src/plaintestreport.pp svneol=native#text/plain
|
packages/fcl-fpcunit/src/plaintestreport.pp svneol=native#text/plain
|
||||||
|
packages/fcl-fpcunit/src/simpletestrunner.pas svneol=native#text/pascal
|
||||||
packages/fcl-fpcunit/src/testdecorator.pp svneol=native#text/plain
|
packages/fcl-fpcunit/src/testdecorator.pp svneol=native#text/plain
|
||||||
packages/fcl-fpcunit/src/testregistry.pp svneol=native#text/plain
|
packages/fcl-fpcunit/src/testregistry.pp svneol=native#text/plain
|
||||||
packages/fcl-fpcunit/src/testreport.pp svneol=native#text/plain
|
packages/fcl-fpcunit/src/testreport.pp svneol=native#text/plain
|
||||||
|
@ -113,6 +113,13 @@ begin
|
|||||||
AddUnit('latextestreport');
|
AddUnit('latextestreport');
|
||||||
AddUnit('plaintestreport');
|
AddUnit('plaintestreport');
|
||||||
end;
|
end;
|
||||||
|
T:=P.Targets.AddUnit('simpletestrunner.pas');
|
||||||
|
with T.Dependencies do
|
||||||
|
begin
|
||||||
|
AddUnit('fpcunit');
|
||||||
|
AddUnit('fpcunitreport');
|
||||||
|
AddUnit('plaintestreport');
|
||||||
|
end;
|
||||||
|
|
||||||
{$ifndef ALLPACKAGES}
|
{$ifndef ALLPACKAGES}
|
||||||
Run;
|
Run;
|
||||||
|
72
packages/fcl-fpcunit/src/simpletestrunner.pas
Normal file
72
packages/fcl-fpcunit/src/simpletestrunner.pas
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
{ This unit contains the TTestRunner class, a base class for the a simple
|
||||||
|
console test runner for fpcunit that can be used with FPC's testsuite. It only
|
||||||
|
generates a plain test report, always runs all tests and sets the exitcode.
|
||||||
|
|
||||||
|
Copyright (C) 2006 Vincent Snijders (original consoletestrunner.pas)
|
||||||
|
Copyright (C) 2016 Sven Barth
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU Library General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or (at your
|
||||||
|
option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Library General Public License
|
||||||
|
along with this library; if not, write to the Free Software Foundation,
|
||||||
|
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
}
|
||||||
|
unit simpletestrunner;
|
||||||
|
|
||||||
|
{$mode objfpc}{$H+}
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses
|
||||||
|
custapp, Classes, SysUtils, fpcunit, testregistry,
|
||||||
|
fpcunitreport, plaintestreport;
|
||||||
|
|
||||||
|
const
|
||||||
|
Version = '0.1';
|
||||||
|
|
||||||
|
type
|
||||||
|
{ TTestRunner }
|
||||||
|
|
||||||
|
TTestRunner = class(TCustomApplication)
|
||||||
|
protected
|
||||||
|
procedure DoRun; override;
|
||||||
|
function DoTestRun(ATest: TTest): Boolean;
|
||||||
|
end;
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
function TTestRunner.DoTestRun(ATest: TTest): Boolean;
|
||||||
|
var
|
||||||
|
ResultsWriter: TCustomResultsWriter;
|
||||||
|
TestResult: TTestResult;
|
||||||
|
begin
|
||||||
|
ResultsWriter := TPlainResultsWriter.Create(Nil);
|
||||||
|
TestResult := TTestResult.Create;
|
||||||
|
try
|
||||||
|
TestResult.AddListener(ResultsWriter);
|
||||||
|
ATest.Run(TestResult);
|
||||||
|
ResultsWriter.WriteResult(TestResult);
|
||||||
|
Result := (TestResult.NumberOfErrors = 0) and (TestResult.NumberOfFailures = 0);
|
||||||
|
finally
|
||||||
|
TestResult.Free;
|
||||||
|
ResultsWriter.Free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TTestRunner.DoRun;
|
||||||
|
begin
|
||||||
|
if not DoTestRun(GetTestRegistry) then
|
||||||
|
ExitCode := 1;
|
||||||
|
Terminate;
|
||||||
|
end;
|
||||||
|
|
||||||
|
end.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user