Hi, Please see attached test project. I have a decorator class and a test class. In the initialization section I call RegisterTestDecorator(), but when I run the test suite, it shows 0 tests ran and 0 tests available in the test suite. I'm using FPC 2.6.4.
How do you use test decorators in FPCUnit? Here is the output. ======================================= $ ./project1 --format=plain -l calling.... constructor TMySpeedTest.Create calling.... constructor TMySpeedTest.Create calling.... constructor TMySpeedTest.Create calling.... constructor TMySpeedTest.Create TestSuites: ======================================= ======================================= $ ./project1 --format=plain -a calling.... constructor TMySpeedTest.Create calling.... constructor TMySpeedTest.Create calling.... constructor TMySpeedTest.Create calling.... constructor TMySpeedTest.Create Time:00.000 N:0 E:0 F:0 I:0 Number of run tests: 0 Number of errors: 0 Number of failures: 0 ======================================= Regards, - Graeme - -- fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/
program project1; {$mode objfpc}{$H+} uses consoletestrunner, fpcunit, speedtests; var lApp: TTestRunner; begin lApp := TTestRunner.Create(nil); try lApp.Run; finally lApp.Free; end; end.
unit speedtests; {$mode objfpc}{$H+} interface uses Classes, SysUtils, fpcunit, testregistry, testdecorator; type TRepeatedTest = class(TTestDecorator) private FRepeatCount: integer; public constructor Create; function CountTestCases: integer; override; procedure BasicRun(AResult: TTestResult); override; property RepeatCount: integer read FRepeatCount write FRepeatCount; end; TMySpeedTest = class(TTestCase) public constructor Create; override; published procedure TestSpeed; procedure TestSpeed2; procedure TestSpeed3; procedure TestSpeed4; end; implementation { TMySpeedTest } constructor TMySpeedTest.Create; begin inherited Create; Writeln('calling.... constructor TMySpeedTest.Create'); end; procedure TMySpeedTest.TestSpeed; begin Check(true); end; procedure TMySpeedTest.TestSpeed2; begin Check(true); end; procedure TMySpeedTest.TestSpeed3; begin Check(true); end; procedure TMySpeedTest.TestSpeed4; begin Check(true); end; { TRepeatedTest } constructor TRepeatedTest.Create; begin FRepeatCount := 5; end; function TRepeatedTest.CountTestCases: integer; begin Result := inherited CountTestCases * FRepeatCount; end; procedure TRepeatedTest.BasicRun(AResult: TTestResult); var i: integer; begin i := FRepeatCount; while i > 0 do begin inherited BasicRun(AResult); dec(i); end; end; initialization RegisterTestDecorator(TRepeatedTest, TMySpeedTest); end.
_______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal