[fpc-pascal] Testing applications with FPCUnit
Michael Van Canneyt
michael at freepascal.org
Sat Dec 17 17:33:10 CET 2011
On Sat, 17 Dec 2011, Luciano de Souza wrote:
> Michael,
>
> I have a meaningful peculiarity: I am blind and I use Freepascal only in the console interface, reading all the output by means of my screen reader.
> Lazarus and Freepascal console IDE are both inaccessible. But, fortunately, for me, it's easy to call the compiler passing parameters at the command line.
>
> I can compile using callings like:
> fpc test.pas
> fpc -XX test.pas
> fpc test.pas -Fu./pas -FE./exe
>
> I really thank Freepascal developers. The reachness of its command line allow me to access the features of the compiler.
>
> For these reasons, it's not possible to open Lazarus and compile the project using its interface. My screen reader has an awful response in this
> environment.
>
> After reading your message, I ask for a help. A friend told me fpcunit depends on FPCUnitConsole... Well, I don't remember exactly the name, but it's a
> Lazarus package.
>
> Observe I need to compile in the console. If it's possible to run the executable, but it's not possible to compile in the command line, I won't be able to
> use FPCUnit.
>
> You said that I need to use '--format=plain' '--all'. I tried:
> fpc apptest.pas --format=plain -all
> And also:
> fpc apptest
> apptest --format=plain -alll
> But, in both cases, I got no result.
> I don't know how to embody this parameters in my compilation tasks.
>
> So I ask you: Is it possible to use FPCUnit only in the command line, it means, compiling and executing in console?
It is possible to do this.
The necessary functionality is contained in the consoletestrunner unit.
I have attached the 'consoletestrunner' unit in a zip file.
It is part of Lazarus, but can be used independent of lazarus;
there are no dependencies on the LCL.
Copy it to the directory where your source code is.
Then use the following test program:
-----------------------------------------------------------------------
program runtests;
{$mode objfpc}{$H+}
uses
Classes, consoletestrunner;
var
App: TTestRunner;
begin
App := TTestRunner.Create(nil);
App.Initialize;
App.Title := 'FPCUnit Console runner.';
App.Run;
App.Free;
end.
-----------------------------------------------------------------------
And then add the units containing your tests to the uses clause. Compile this program.
After that, the commandline options for this program will work as I explained.
Michael.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: consoletestrunner.zip
Type: application/zip
Size: 3084 bytes
Desc:
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20111217/cb275e13/attachment.zip>
More information about the fpc-pascal
mailing list