[fpc-pascal] FPCUnit - how to register decorator tests?

Graeme Geldenhuys mailinglists at geldenhuys.co.uk
Thu Jul 23 11:06:09 CEST 2015

On 2015-07-20 23:00, 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 running at all.

To 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.

  - Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal

More information about the fpc-pascal mailing list