You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using the prebuilt Mockolate v0.12.4 from here, and the latest version of FlexUnit that comes with FlashBuilder Professional (FlexUnit 4.1 I think).
My code looks like this:
package MyTestPackage
{
import com.my.site.MyClass;
import flash.events.Event;
import mockolate.*;
import org.flexunit.Assert;
import org.flexunit.async.Async;
public class MyClassTests
{
[Before(async, timeout = 5000)]
public function prepareMockolates():void
{
Async.proceedOnEvent(this,
prepare(MyClass),
Event.COMPLETE);
}
[Test]
public function mocksWorkTest():void
{
var myClass:MyClass = strict(MyClass);
//The above line throws an exception, so what I put here doesn't matter
}
}
}
The line
var myClass:MyClass = strict(MyClass);
throws an exception
Error: InstanceRecipeBuilder.withClassRecipe
at mockolate.ingredients::InstanceRecipeBuilder/withClassRecipe(InstanceRecipeBuilder.as:21)
at mockolate.ingredients::Mockolatier/mockolate.ingredients.only::createInstanceRecipeFor(Mockolatier.as:183)
at mockolate.ingredients::Mockolatier/strict(Mockolatier.as:167)
at global/mockolate::strict(strict.as:28)
**[ at MyTestPackage::MyClassTests/mocksWorkTest(MyClassTests.as:22) ]
at Function/http://adobe.com/AS3/2006/builtin::apply
at flex.lang.reflect::Method/apply(Method.as:244)
at org.flexunit.runners.model::FrameworkMethod/invokeExplosively(FrameworkMethod.as:201)
at org.flexunit.internals.runners.statements::InvokeMethod/evaluate(InvokeMethod.as:72)
at org.flexunit.internals.runners.statements::RunBeforesInline/handleSequenceExecuteComplete(RunBeforesInline.as:112)
at org.flexunit.token::AsyncTestToken/sendResult(AsyncTestToken.as:107)
at org.flexunit.internals.runners.statements::AsyncStatementBase/sendComplete(AsyncStatementBase.as:76)
at org.flexunit.internals.runners.statements::StatementSequencer/sendComplete(StatementSequencer.as:172)
at org.flexunit.internals.runners.statements::StatementSequencer/handleChildExecuteComplete(StatementSequencer.as:145)
at org.flexunit.token::AsyncTestToken/sendResult(AsyncTestToken.as:107)
at org.flexunit.internals.runners.statements::ExpectAsync/sendComplete(ExpectAsync.as:560)
at org.flexunit.internals.runners.statements::ExpectAsync/handleAsyncEventFired(ExpectAsync.as:431)
at flash.events::EventDispatcher/dispatchEventFunction
at flash.events::EventDispatcher/dispatchEvent
at org.flexunit.async::AsyncHandler/handleEvent(AsyncHandler.as:156)
at flash.events::EventDispatcher/dispatchEventFunction
at flash.events::EventDispatcher/dispatchEvent
at Function/http://adobe.com/AS3/2006/builtin::apply
at SetIntervalTimer/onTimer
at flash.utils::Timer/_timerDispatch
at flash.utils::Timer/tick
The same thing happens when using nice().
If I create mocked fields using MockolateRule everything works perfectly, but of course that greatly reduces the flexibility of my tests, since I can no longer create mocks within the tests.
Does anyone know why this is happening or how to fix it?
The text was updated successfully, but these errors were encountered:
I believe it is to do with trying to mock concrete classes instead of interfaces. If the concrete class throws an error in the constructor then you get this error.
Using the prebuilt Mockolate v0.12.4 from here, and the latest version of FlexUnit that comes with FlashBuilder Professional (FlexUnit 4.1 I think).
My code looks like this:
The line
throws an exception
The same thing happens when using
nice()
.If I create mocked fields using
MockolateRule
everything works perfectly, but of course that greatly reduces the flexibility of my tests, since I can no longer create mocks within the tests.Does anyone know why this is happening or how to fix it?
The text was updated successfully, but these errors were encountered: