[fpc-pascal] Re: FPCUnit without Lazarus

Sven Barth pascaldragon at googlemail.com
Sun Jan 8 13:31:30 CET 2012


The unit consoletestrunner from $lazarusdir/components/fpcunit/console 
might still be useful to you, because it allows writting the testresults 
to the console. The unit has NO dependencies to the LCL, so you can 
simply copy it and compile it along with your tests. Normally you use it 
like this (I have not tested it and thus I'm just guessing based on the 
unit's code):

program mytestrunner;

uses
   consoletestrunner, // this is the unit copied from Lazarus
   testunit1, // these are your test units
   testunit2;

begin
   with TTestRunner.Create do
     try
       Run;
     finally
       Free;
     end;
end;

Your tests then register themselves to the testsuite in the 
initialization section of their unit.

Regards,
Sven

On 08.01.2012 13:13, Luciano de Souza wrote:
> Now, I understand. FPCUnit and FPCRegistry do not have LCL dependences.
> What depends on LCL is the runner called Console Runner. This name make
> me confused!
>
> I ahve alredy read the documentation, but I could not understand.
> Perhaps, perhaps my weak english... Well, the fact is that everything is
> now OK.
>
> When I read the documentation I didn't understand the runner was a
> separated executable: an application built specially to test my program.
>
> I thought all the code needed to test my program would be in my test
> unit. I was able to create, to register the tests, but not to run then.
> I was searching something to run in FPCUnit and FPCRegister. All the
> code required to run my test would be in the initialization of my test
> unit. When compiling my application I would do:
>
> program MyApp;
> uses
> MyUnit,
> {$ifdef tst}
> MyUnitTest;
> {$endif}
>
> And I call: fpc MyApp.pas -dtest. According to this idea, the runner
> would be my own application called with certain commandline options.
>
> Yes, in my first reading, I do not understand it. Now I can see the
> adopted model is best. I don't need to mix the code of my application
> with test code. "{$ifdef ...}" is not required.
>
> In brief, all my problem was that I could understand that I have a
> runner and I will need to compile it each time I create a new project.
>
> Solved my interpretation issues, now I am coming back to the tests.
>
> Thank you very much for the attention!
>
> Regards,
>
> Luciano
>
> Em 08-01-2012 00:14, leledumbo escreveu:
>> FPCUnit is part of FCL and it doesn't require LCL. Of course if you
>> install
>> via packages under Lazarus components folder, it would depend on Lazarus
>> parts (e.g, LCL), esp. for the runner. Open
>> fpc/packages/fcl-fpcunit/src/demo for a pure FPC example. Or
>> http://free-pascal-general.1045716.n5.nabble.com/file/n5128730/fpcunit.pdf
>>
>> here for the documentation.
>>
>> --
>> View this message in context:
>> http://free-pascal-general.1045716.n5.nabble.com/FPCUnit-without-Lazarus-tp5128696p5128730.html
>>
>> Sent from the Free Pascal - General mailing list archive at Nabble.com.
>> _______________________________________________
>> fpc-pascal maillist - fpc-pascal at lists.freepascal.org
>> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
> _______________________________________________
> fpc-pascal maillist - fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal




More information about the fpc-pascal mailing list