Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2016-09

TTestSuite

6 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

José Mejuto

Hello,

In the TTestSuite class when process is finished a XML is written to stdout. If the tests may show some kind of progress information, for manually run tests, this information must be in stdout, stderr, is there a specific method available for progress output ?

Cheers,

José Mejuto

Michael Van Canneyt
to José Mejuto
José Mejuto wrote 6 lines
Hello, In the TTestSuite class when process is finished a XML is written to stdout. If the tests may show some kind of progress information, for manually run tests, this information must be in stdout, stderr, is there a specific method available for progress output ?

No. But I think this could be useful.

Michael.

Graeme Geldenhuys
to José Mejuto: In the TTestSuite class when process is finished a XML is written to stdout. If the tests…
José Mejuto wrote
If the tests may show some kind of progress information

I'm assuming you are talking about FPCUnit?

If so, there is already a test progress listener implemented in the form of the TProgressWriter class (see the consoletestrunner.pas unit).

Simply run your test suite from the command line and specify the -p (or --progress) command line parameter.

If that's not the output you need, simply define a new class that implements the ITestListener interface and let any of the following methods output the information you need.

    { ITestListener interface requirements }
    procedure AddFailure(ATest: TTest; AFailure: TTestFailure);
    procedure AddError(ATest: TTest; AError: TTestFailure);
    procedure StartTest(ATest: TTest);
    procedure EndTest(ATest: TTest);
    procedure StartTestSuite(ATestSuite: TTestSuite);
    procedure EndTestSuite(ATestSuite: TTestSuite);

I used to have multiple listener class for various "progress output". It takes a minute or two to put a new class together.

Alternatively, there is also the FPTest framework. It's console test runner also has test progress output and also use a ITestListener interface. In fact, I modelled the FPCUnit implementation based on DUnit2 (FPTest is a fork of DUnit2).

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
José Mejuto
to Graeme Geldenhuys
Graeme Geldenhuys wrote 8 lines
> If the tests may show some kind of progress information I'm assuming you are talking about FPCUnit? If so, there is already a test progress listener implemented in the form of the TProgressWriter class (see the consoletestrunner.pas unit). Simply run your test suite from the command line and specify the -p (or --progress) command line parameter.

Hello,

Yes, but I'm writing the test so in code I can write something like:

if a=0 then FAIL('Value must not be 0');

And I wish to write something like:

if a>1 then MESSAGE('Value 2 or bigger is OK');
if a=1 then MESSAGE('Value 1 is quite dangerous');
if a=0 then FAIL('Value 0 is KBOOM!');

Because some test are sloooow and I like to have a screen feedback when running manually in the console, but if I use the writeln this information will pollute the generated XML to stdout. Maybe using stderr for progress messages will be valid and that's my question, will stderr cause pollution when the test is added to an automated test set ?

PS: I need to contact you out of the list about a project I'm finishing and that would be of your interest. My last try looking for your email (not ) was unsuccessful and never get an answer. Could you please contact me to this email address ? Thank you.

Graeme Geldenhuys
to José Mejuto
José Mejuto wrote
but if I use the writeln this information will pollute the generated XML to stdout.

Why not specify a output file for the generated XML, instead of letting it go to stdout. Run the FPCUnit console test application with the -h parameter to see what options are available. Maybe that will help.

Maybe using stderr for progress messages will be valid and that's my question, will stderr

Probably not ideal, but I guess it could work. Otherwise, try the above (specify a XML output file), then see what happens with writeln() statements to stdout.

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
José Mejuto
to Graeme Geldenhuys
Graeme Geldenhuys wrote
> information will pollute the generated XML to stdout. Why not specify a output file for the generated XML, instead of letting it go to stdout. Run the FPCUnit console test application with the -h parameter to see what options are available. Maybe that will help.

Hello,

With file output there is no problem as only the XML data is stored there, so writeln could be valid as a progress indicator because I think that stdout will not be used by automated tools.

Best regards and thanks.