Graeme Geldenhuys wrote:
>> On fpc I used fpcunit, and I tried to use DUnit with Delphi. That works,
>> but the problem is that where fpcunit uses 'assertequals(prop1,prop2)'
>> dunit uses 'testequals(prop1,prop2)'
>>
>> So that I'm still unable to write a test only once, and test it with
>> both compilers.
> 
> For tiOPF we use DUnit under Delphi and fpcUnit under FreePascal. Only
> have a single test under both compilers.  Because the DUnits test
> were written first, I created a compatibility unit to be used under
> FreePascal.  All our test inherit from TtiTestCase instead of directly
> from TTestCase.  This made it really easy to add my compatability code
> for FreePascal.  Previously I included my  DUnitCompatableInf.inc
> directly into the TTestCase class of fpcUnit, but adding it to
> TtiTestCase ended up being a much simpler thing to do.
> 
> Example:
> ------------------------------
>  TtiTestCase = class( TTestCase )
>  private
>    [....]
>  protected
>    [....]
>  public
>    {$IFDEF FPC}
>      {$I DUnitCompatableIntf.inc}
>    {$ENDIF}
>  end ;
> ------------------------------
> 
> Example DUnitCompatableIntf.inc:
> ------------------------------
> procedure TtiTestCase.CheckEquals(expected, actual: extended; msg: string);
> begin
>  AssertEquals(msg, expected, actual);
> end;
> ------------------------------
> 
> 
> If you wanted the complete DUnitCompatableIntf.inc file, I can send it
> to you.  I still think we should add it into fpcUnit as well for any
> other projects having existing DUnit code and moving to fpcUnit. Dean?
Yes, I've seen the tests in the tiOPF svn repository.
I think it's a good idea to add this compatibility code to fpcunit with
a little improvement: I would declare the CheckEquals methods as class
methods, to be able to use them outside the TTestCase class.

Ciao, Dean

_________________________________________________________________
     To unsubscribe: mail [EMAIL PROTECTED] with
                "unsubscribe" as the Subject
   archives at http://www.lazarus.freepascal.org/mailarchives

Reply via email to