[fpc-pascal] order of unit tests

Graeme Geldenhuys graemeg.lists at gmail.com
Mon Dec 8 08:46:29 CET 2008


On Sun, Dec 7, 2008 at 12:10 PM, Marc Santhoff <M.Santhoff at t-online.de> wrote:
>
> Yes, I agree. But if I do the same reading process in the readers source
> and in the test case I have two spots having the same code. Fixing
> errors or making changes at one place only would be nice.
>
> How could I solve this problem in a better way?

By using Setup() or TearDown().  You can also use class inheritance.
Create TTestCase descendants implementing your readers source. Then
create your actual test cases, using that new class, instead of
TTestCase directly.

eg:
    TTestCase
            |
    TMyBaseReaderTestClass   <------ will contain your reader code
            |
    TReaderTestCase           <-- will contain your actual tests


or


    TReaderTestCase = class(TTestCase)
    public
       procedure Setup;          <--- reader setup code here
       procedure TearDown;
    published
       procedure TestOne;
       procedure TestTwo;
       ....
    end;


Setup() and TearDown() will be called automatically before and after each test.


Regards,
  - Graeme -


_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/



More information about the fpc-pascal mailing list