[fpc-pascal] Running tests with FPC units only

luciano de souza luchyanus at gmail.com
Sun Nov 11 18:29:31 CET 2018


Hello hall,
I am blind, so I don't use Lazarus. In pure Freepascal, I tried to run
an example test:

program tester;
{$mode objfpc}{$H+}

uses
fpcunit, testregistry;

type
TMyTest = class(TTestCase)
published
procedure TestSomething;
end;

procedure TMyTest.TestSomething;
begin
AssertEquals(1, 1);
end;

BEGIN
RegisterTest(TMyTest);
END.

This code compiles, but doesn't do anything. Here tests were only
registered, not run.
For this purpose, acording example I found in FPC examples directory,
I need the class TTestRunner.

BEGIN
with TTestRunner.create(nil) do
begin
try
initialize;
run;
finally
free;
end;
end;
END.

However, TTestRunner belongs to consoletestrunner, a non Freepascal unit.
I imagine there is a way to run tests only with Freepascal units. But
how to do this without consoletestrunner, a unit found in Lazarus?
Best regards,

-- 
Luciano de Souza



More information about the fpc-pascal mailing list