Tuesday 27 April 2010

Testing Thrown Error Handling

A quick way to test thrown errors are behaving as expected.

[Test]
public function testErrorHandling():void
        {
           

            var errorThrown:Boolean = false;
           
            try
            {
                callMethodThatCausesError();
            }
            catch (e:Error)
            {
                errorThrown = (e.message == 'SomeClass.ERROR_IN_DATA_MESSAGE');
            }
           
            assertTrue(errorThrown);
        }

Posted via email from fasanya's posterous

No comments: