Sign in Join

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

Mailing lists / fpc-pascal / 2015-07

FPCUnit - how to register decorator tests?

2 messages · 1 person · –

Reply by email Subscribe to this list Your subscription

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

Graeme Geldenhuys

Hi,

Please see attached test project. I have a decorator class and a test class. In the initialization section I call RegisterTestDecorator(), but when I run the test suite, it shows 0 tests ran and 0 tests available in the test suite. I'm using FPC 2.6.4.

How do you use test decorators in FPCUnit?

Here is the output.

=======================================
$ ./project1 --format=plain -l
calling.... constructor TMySpeedTest.Create
calling.... constructor TMySpeedTest.Create
calling.... constructor TMySpeedTest.Create
calling.... constructor TMySpeedTest.Create
TestSuites:
=======================================

=======================================
$ ./project1 --format=plain -a
calling.... constructor TMySpeedTest.Create
calling.... constructor TMySpeedTest.Create
calling.... constructor TMySpeedTest.Create
calling.... constructor TMySpeedTest.Create
Time:00.000 N:0 E:0 F:0 I:0

Number of run tests: 0
Number of errors: 0
Number of failures: 0

=======================================

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/
Graeme Geldenhuys
to Graeme Geldenhuys
Graeme Geldenhuys wrote
How do you use test decorators in FPCUnit?

Just a follow-up on what was wrong. My usage and registration of a decorator was correct, but I believe I uncovered another bug in FPCUnit, hence my test suite reported 0 tests.

The FPCUnit's decorator is a class and has two overloaded constructors. In my TRepeatableTest decorator I used the constructor to set up some stuff I needed, but for some magical reason the decorator class's constructors are somehow NEVER called (simple writeln() can confirm that). That in turn rendered my example test project useless with no tests fix my problem with the TRepeatedTest decorator, I had to override the Run() method (which is actually called), and place all my setup code there, and remove any usage of the constructors in the decorator class. After that my TRepeatedTest decorator worked.

Regards,
- Graeme -

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