[fpc-pascal] The testcase example doesn't generate plain text report

Graeme Geldenhuys mailinglists at geldenhuys.co.uk
Tue Nov 15 14:51:03 CET 2016


On 2016-11-15 09:06, luciano de souza wrote:
> So I runned the test with the following commandline:
> 
> ./testrunner -a --format=plain
> 
> However, the output produced was in XML.

I had a quick look at the source code of the demo included with FPCUnit.
Interestingly, it defines its own test runner and only handles XML or
LaTeX for the -l command line parameter - all other output is hard-coded
to XML. The demo doesn't use the consoletestrunner.pp unit for some reason.

If however you create your own test project, use the
consoletestrunner.pp unit, which defines TTestRunner. Use that as your
base class for your test suite application. It will then correctly
support the --format parameter for test output as well as test listing
results.

for example:


===================================
program mytests;

{$mode objfpc}{$H+}

uses
  Classes
  ,consoletestrunner
  // All test units go in here - shared between GUI and Console runners
  {$i testunits.inc}
  ;

type
  TMyTestRunner = class(TTestRunner)
  protected
  // override the protected methods of TTestRunner to customize its behavior
  end;

var
  Application: TMyTestRunner;

begin
  DefaultFormat:=fPlain;
  DefaultRunAllTests:=True;
  Application := TMyTestRunner.Create(nil);
  Application.Initialize;
  Application.Run;
  Application.Free;
end.
===================================


Regards,
  Graeme

-- 
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp



More information about the fpc-pascal mailing list