Graeme Geldenhuys wrote:
> Hi Dean,
> 
> I wrapped our DB Connection code in a TTestSetup decendent class.  I
> registered the test case with:
> RegisterTestDecorator(TDBConnectionSetupDecorator, TTreeviewFormTest);
> 
> Executing the complete TTreeviewFormTest test case from the GUI Test
> Runner works fine.  Selecting a individual test fails, as it never
> executes the test decorator.  I created a breakpoint it my
> TDBConnectionSetupDecorator.OneTimeSetup;
> procedure, and it never reached it.
> 
> 
> I had a look at the code, but can't quite figure out where the problem
> is.  :(
> 
> I have an idea that it might be related to the following code in
> TGUITestRunner.BuildTree() but for the life of me I a can't see what.
> 
>    node := TestTree.Items.AddChildObject(rootNode,
> ASuite.Test[i].TestName, ASuite.Test[i]);
>    if ASuite.Test[i] is TTestSuite then
>      BuildTree(Node, TTestSuite(ASuite.Test[i]))
>    else
>      if TObject(ASuite.Test[i]).InheritsFrom(TTestDecorator) then
>        BuildTree(Node, TTestSuite(TTestDecorator(ASuite.Test[i]).Test));
> 
> 
> Regards,
>  - Graeme -
> 
> 
When you select an individual test it is not a TTestSetup descendent so
it's not wrapped between a call to OneTimeSetup and OneTimeTeardown.
The problem is in the way the TTestSetup objects are created when
registered:

procedure RegisterTestDecorator(ADecoratorClass: TTestDecoratorClass;
ATestClass: TTestCaseClass);
 begin

GetTestRegistry.AddTest(ADecoratorClass.Create(TTestSuite.Create(ATestClass)));
 end;

As you can see to create the child tests I've done simply
TTestSuite.Create(ATestClass), whereas I should have constructed the
child tests as some TTestSetup themselves, to be wrapped in OneTimeSetup
and OneTimeTeardown.

Thank you for pointing out the bug, it never surfaced because I rarely
use the TestDecorators (I'm trying to avoid the TestDecorators as they
are breaking the isolation rule in testing).
Anyway I'll try to fix it as soon as possible.
Ciao, Dean

_________________________________________________________________
     To unsubscribe: mail [EMAIL PROTECTED] with
                "unsubscribe" as the Subject
   archives at http://www.lazarus.freepascal.org/mailarchives

Reply via email to