How to stop a test run/how to access the RunNotifier.pleaseStop()?
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
