Sorry for asking after delay, but I run into some troubles.
I decided to use FPCUnit. But I cannot find enough information or docs for it.
1) When I created test application from samples and tried to run it, I got:
fpcunitproject1.lpr(6,22) Fatal: Cannot find GuiTestRunner used by FPCUnitProject1.
That's looks strange, sample doesn't work....
I use: FPC 3.0.2 and Lazarus 1.6.4+dfsg-1, 64 bit, Ubuntu 17.04
Well, I am fine with console version, but still...
2) I want to have separate test suite for each modules group (simpler - a subfolder of project). Also I want to run all tests.
How can I reach it?
For now I have error:
testregistrator.pas(18,42) Error: Incompatible type for arg no. 2: Got "Class Of TGroupXTestSuite", expected "TTest"
I cannot use RegisterTest for TestSite, despite tutorial which I googled says I can (maybe it outdated
a bit ?)
My code:
// The application file is autogenerated, I only added TestRegistrator in uses section
unit TestRegistrator;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, fpcunit, testutils, testregistry,
GroupXTestSuite;
implementation
procedure RegisterAllTests();
begin
// TTestSuite -> TTest -> TObject
// TTestCase -> TAssert -> TTest -> TObject
// procedure RegisterTest(ASuitePath: String; ATest: TTest); overload;
RegisterTest('GroupX', TGroupXTestSuite); // <---- Error is here.
end;
initialization
RegisterAllTests();
end.
unit TGroupXTestSuite;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, fpcunit, testregistry,
SomeTestCase;
type
TGroupXTestSuite = class(TTestSuite)
published
procedure RegisterSuiteTests();
end;
implementation
procedure TGroupXTestSuite.RegisterSuiteTests();
begin
RegisterTest(TSomeTestCase);
end;
end.
unit TSomeTestCase;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, fpcunit, testutils, testregistry;
type
{ TTestCase1 }
TSomeTestCase = class (TTestCase)
protected
procedure SetUp(); override;
procedure TearDown(); override;
published
procedure TestHookUp;
end;
implementation
procedure TSomeTestCase.SetUp();
begin
end;
procedure TSomeTestCase.TearDown();
begin
end;
procedure TSomeTestCase.TestHookUp;
begin
Fail('Write your own test');
end;
initialization
end.