Skip to main content
July 8, 2009
Question

How to stop a test run/how to access the RunNotifier.pleaseStop()?

  • July 8, 2009
  • 1 reply
  • 1299 views

This may be a possible enhancement...

I was trying to figure out how to allow the user to stop a test run, by hitting a button that routed to the RunNotifier.as pleaseStop() method.

However, it doesn't look like there is any way to access this notifier off of the FlexUnitCore object.  The notifier is private, and there's not other way to get a handle on the notifier from the FlexUnitCore perspective - which is what the UI has access to.  While a Runner gets passed a notifier instance, the Runner is not interacting with the outer application controlling the flexunit test run.

Though the FlexUnitCore notifier variable is of a IRunNotifier interface type (which doesn't define pleaseStop()), since the variable isn't public and since it is always a RunNotifier.as implementation when the FlexUnitCore constructor creates it, it should be safe to expose methods that only exist on it through the FlexUnitCore.

I'd like to see either of these enhancements on the FlexUnitCore.as class for allowing the user to have the ability to stop a test run:

1) add a public pleaseStop() method on FlexUnitCore, and have it call the RunNotifier's pleaseStop() method.

    public function pleaseStop():void {

        if (notifier && notifier is RunNotifier) {

            RunNotifier(notifier).pleaseStop();

        }

    }

2) or add a public getter for the RunNotifier on the FlexUnitCore, which seems more dangerous.

I also experimented with throwing a StoppedByUserException from a test method itself, but this just caused the test method to have an error and didn't propagate outwards.

Thanks,

  Carlos

This topic has been closed for replies.

1 reply

Participant
July 8, 2009

Carlos,

Once the major functionality is completed, this is a feature we absolutely intend to add.

You are correct that this would be an enhancement.  Please make sure to a file a request with JIRA.

https://bugs.adobe.com/jira/browse/FXU

Thanks,

Joe