The ParentRunner is the base class for the FlexUnit 4 Runners. When the run method is called by FlexUnit4Core a few things take place. An AsyncTestToken is created and a notificationMethod is added to it, this method will be the handler for when this particular FlexUnit 4 class is completed. The notifier is stored inside the token as well for use in the result handler. The classBlock method is where all the Befores, Afters and Tests are sequenced and run.

public function run( notifier:IRunNotifier, previousToken:AsyncTestToken ):void {
     var testNotifier:EachTestNotifier = new EachTestNotifier(notifier, description );
     var resendError:Error;
			
     var token:AsyncTestToken = new AsyncTestToken( ClassNameUtil.getLoggerFriendlyClassName( this ) );
     //Add a reference to the previousToken in this runner's token
     token.previousToken = previousToken;
     token.addNotificationMethod( handleRunnerComplete );
     token[ EACH_NOTIFIER ] = testNotifier;

     try {
          var statement:IAsyncStatement = classBlock( notifier );
          statement.evaluate( token );
     } catch ( error:AssumptionViolatedException ) {
          resendError = error;
          testNotifier.fireTestIgnored();
     } catch ( error:StoppedByUserException ) {
          resendError = error;
          throw error;
     } catch ( error:Error ) {
          resendError = error;
          testNotifier.addFailure( error );
     }
			
     if ( resendError ) {
          previousToken.sendResult( resendError );
     }
}
  • No labels