Skip to main content
May 29, 2009
Question

Using validateNow to test UIComponents

  • May 29, 2009
  • 1 reply
  • 1346 views

I've been using validateNow() in my test setup methods to force UIComponents to finish their creationComplete handling before a new test actually runs. This works most of the time, but I've had some wierd errors occassionally, and I've tracked them down to cases where the object is not fully initalized after validateNow returns.

Are there cases where validateNow() will defer execution of the usual commitProperties/measure/updateDisplayList sequence?

The happy path (which is 99% of the time) looks like:

setUp() -> calls validateNow() -> calls obj.creationComplete

test method runs

tearDown -> calls removeChild() and validateNow

But when the problem happens, the execution order is

setUp() -> calls validateNow()

test method runs

tearDown -> calls removeChild() and validateNow()

obj.creationComplete fires and crashes

One of the really nasty parts here is that the exception is thrown outside of the execution of the test method, which means when this problem

happens in an unattended nightly build process, the debug Flash player hosting the test SWF throws up an exception dialog and the entire test

harness hangs until some build timeout expires to kill the process.

This topic has been closed for replies.

1 reply

Participating Frequently
May 29, 2009

Yeh, that's going to work a good portion of the time, but there is an assumption here that everything you are doing is going to happen in a single validation cycle.

Have you looked at any of the things in FU4 that allow you to wait for an event such as initialize or creationComplete in your setup before you run your tests?

Mike

May 29, 2009

Just to be clear - you're saying that my assumption is wrong?

No - I haven't looked at FlexUnit 4, but I will now

Thanks,

Glenn

Participating Frequently
May 29, 2009

Glenn,

There are cases, viewstack is an easy one that comes to mind that don't finish in a single pass. There are likely some edge cases in a lot of components where this could happen too.

mike