views:

9

answers:

1

Hello, I"m a bit confused because FlexUnith 4's behavior. When I use fail() in try-catch body fail method is just ignored.

[Test]
        public function extend():void
        {   
            try {
                fail("This should fail");                   
            } catch(er:Error) {}

        }

I suppose this one should fail as there is no way around it, but it succeeds and turns green. Whatam I doing wrong? When i put fail() before try-catch block it fails as it is suposed to. BTW using Flash builder 4.

A: 

The way assertions are signaled to the framework is through exceptions. fail sends the failure signal using an exception too. That, and the fact that Error is the base class for all exceptions means that no exception will ever reach the framework (your try/catch block catches all excpetions), which means that the test didn't fail.

Ionuț G. Stan
Thank you. And if you could me help with one more thing as I"m new to AS3 - how can I catch Null pointer exception, I just can"t find something similar to Java' NulPointerException..
uther.lightbringer