OK when trying to reproduce only with FlexUnit stuff it turned out that the second issue may be somehow related to the morefluent and polling as it does not fail the same when used with Async.handleAsync. Not sure what this might be if I can't reproduce it with bare flex unit I'll give you the morefluent case.
Here is the code for the first issue:
package {
import flash.events.Event;
import org.flexunit.async.Async;
import org.flexunit.rules.IMethodRule;
public class RuleDoesNotEnableAsyncWhenBeforeHasAsync
{
[Rule]
public var rule:IMethodRule = new AsyncRule();
[Before(async)]
public function setUp():void
{
}
[Test]
public function shouldBeRecognizedAsAnAsyncTest():void
{
Async.asyncHandler(this,
function (e:Event = null, passThrough:* = null):void
{
},
1000);
}
}
}
import org.flexunit.internals.runners.statements.ExpectAsync;
import org.flexunit.internals.runners.statements.IAsyncStatement;
import org.flexunit.internals.runners.statements.MethodRuleBase;
import org.flexunit.rules.IMethodRule;
import org.flexunit.runners.model.FrameworkMethod;
import org.flexunit.token.AsyncTestToken;
class AsyncRule extends MethodRuleBase implements IMethodRule
{
public function MorefluentRule()
{
}
override public function evaluate(parentToken:AsyncTestToken):void
{
super.evaluate(parentToken);
proceedToNextStatement();
}
override public function apply(base:IAsyncStatement, method:FrameworkMethod, test:Object):IAsyncStatement
{
//This will tell you if someone marked the method with async already so we don't apply the ExpectAsync code twice
var async:Boolean = ExpectAsync.hasAsync(method);
//If it already has async, then just go ahead and use the existing statement, else wrap it in ExpectAsync
var statement:* = async ? base : new ExpectAsync(test, base);
//You have access to the method and test if you need it
return super.apply(statement, method, test);
}
}