[fpc-devel] fpcUnit demo error

Dean Zobec dezobec at tin.it
Thu Sep 14 21:34:49 CEST 2006


Leonardo M. Ramé ha scritto:
> People, just found an error in the consolerunner/testrunner.pp demo application. It's constructor
> and destrutor differs from the frameworktest sample in the tests directory.
> 
> The correct methods are:
> 
> constructor TTestRunner.Create(AOwner: TComponent);
> begin
>   inherited Create(AOwner);
>   FXMLResultsWriter := TXMLResultsWriter.Create;
>   FSuite := TTestSuite.Create;
>   FSuite.TestName := 'Framework test';
>   FSuite.AddTestSuiteFromClass(TAssertTest);
>   FSuite.AddTest(TSuiteTest.Suite());
> end;
> 
> destructor TTestRunner.Destroy;
> begin
>   FXMLResultsWriter.Free;
>   FSuite.Free;
> end;

No, this is not an error, the test runner in the tests directory runs
the tests of fpcunit itself, so it intentionally does not use the
fpcunit automation to build the testcases through the methods in the
testregistry unit. In fact in the constructor the TTestSuite is built
manually. Sometimes you have to act this way (e.g.  where you  need some
parameterized test cases).
Whereas the test runner in the demo directory uses the registration
mechanism to build the test cases. But there IS an error in the
testrunner in the demo directory, the unit testreport was substituted
with the new xmlreporter that lacks some methods used by the runner.
For Vincent: what if we simply use here your text test runner in the
lazarus/test directory? I'll prepare a patch.
Ciao, Dean




More information about the fpc-devel mailing list