Skip to main content
August 15, 2009
Question

Default order of inherited [Before] functions

  • August 15, 2009
  • 1 reply
  • 1584 views

If I extend a class with [Before] and [After] functions, the default behavior appears to be to execute the inherited functions last. Could I make a plug for having the default behavior "nest" the before and after functions such that the base class functions are the first in and last out? I know I can add ordering metadata (and have tested that this works through inheritance), but maintaining ordering numbers through more than a few levels of inheritance will be a pain.

I'm looking to write basic test code once - any test that needs a document could extend a document-making test class, and any test that required a particular document content setup could extend a base class that made that content (and that base class would have extended the document-making class).

The code below gives this trace order for the testBeforeAfterInheritance test:

before actual

before base

after actual

after base

What I'd like to see is:

before base

before actual

after actual

after base

public class BaseTestClass

{

  [Before]

  public function beforeBase():void

  {

    // this might make a document, for example

    trace ("before base");

  }

  [After]

  public function afterBase():void

  {

    trace ("after base");

  }

}

import com.adobe.muse.testing.framework.BaseTestClass;

public class ActualTestClass extends BaseTestClass

{

  [Before]

  public function beforeActual():void

  {

    // this might add an item to the document

    trace ("before actual");

  }

  [After]

  public function afterActual():void

  {

    trace ("after actual");

  }

  [Test]

  public function testBeforeAfterInheritance():void

  {

  }

}

This topic has been closed for replies.

1 reply

Participating Frequently
August 15, 2009

Yeh, I think you could make that case.

File it for me as an enhancement request in the bug base, I would like to hear other's opinions, but I think this makes sense to me. I am a little scared about what it will take to do with the limited introspection API we have, but will investigate.

Mike

February 23, 2010

I hope the work on https://bugs.adobe.com/jira/browse/FXU-65 will include BeforeClass and AfterClass as well. My experience with defining those methods in a parent class was that they never got called, but it could be that they would have been called last after the subclass's test methods ran. I didn't realize that was a possiblity until I found this posting. By the time my Test methods failed because the set-up code in BeforeClass hadn't run, I didn't keep debugging to see what else might happen.