Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating any mocks throws InstanceRecipeBuilder.withClassRecipe #68

Open
BlueRaja opened this issue Mar 26, 2014 · 5 comments
Open

Creating any mocks throws InstanceRecipeBuilder.withClassRecipe #68

BlueRaja opened this issue Mar 26, 2014 · 5 comments

Comments

@BlueRaja
Copy link

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?

@mikecann
Copy link

mikecann commented Jul 7, 2015

Did you ever solve this? Im having the same problem.

@BlueRaja
Copy link
Author

BlueRaja commented Jul 7, 2015

No, the framework is broken and apparently no one cares about it.

@mikecann
Copy link

mikecann commented Jul 7, 2015

Ahh damn :( Some of us still have legacy projects to maintain!

@mikecann
Copy link

mikecann commented Jul 7, 2015

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.

@mikecann
Copy link

mikecann commented Jul 7, 2015

Scratch all that, the problem was simply because I forgot to prepare on of the dependencies, doh!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants