FlexUnit 4 and mockito 1.3-RC3 possible bug?

26 views
Skip to first unread message

grep

unread,
Jun 11, 2010, 12:25:22 PM6/11/10
to mockito-flex
I have a test that is using the new meta tags to load mocks and I
think there is a bug here. Running the following test failed:

package com.hp.console.cmd.social
{
import com.hp.console.msg.InvalidSessionMsg;
import com.hp.console.util.IFacebookSessionProxy;

import org.flexunit.asserts.assertTrue;

import org.mockito.Mockito;
import org.mockito.integrations.*;


[RunWith("org.mockito.integrations.flexunit4.MockitoClassRunner")]
public class SocialAgentCmdFBTest
{
public function SocialAgentCmdFBTest()
{
}

[Mock(type="com.hp.console.util.IFacebookSessionProxy")]
public var mockFbSession:IFacebookSessionProxy;

private var _fbCmd:SocialAgentCmdFB;

[Before]
public function setup():void
{
_fbCmd = new SocialAgentCmdFB();
}

[Test]
public function shouldAbleToCreateSesisonAndLoadLogginUser():void
{
_fbCmd.fbsession = mockFbSession;

var params:Object = new Object();
params.fb_sig_ss = "ss";

_fbCmd.assignFaceBookSession(params);
verify().that(mockFbSession.createFbSession(params));

}

}
}

with this error:


Error: Wanted but not invoked at all:
asmock.generated:IUrlRequestLoaderProxy79C2AB0937CBA43E58B444B96F870B96EC4184FE/
sendRequest(null/social/people/@me/@self?
fields=name,thumbnailUrl,tags&format=xml&pt=HP&st=null&count=1&timestamp=1276273389897,function
Function
at org.mockito.impl::Times/verify(Times.as:51)
at org.mockito.impl::MockInterceptorImpl/
methodCalled(MockInterceptorImpl.as:61)
at org.mockito.impl::AsmockMockery/methodCall(AsmockMockery.as:101)
at ASMockInterceptor/intercept(ASMockInterceptor.as:32)
at org.mockito.asmock.framework.proxy::InterceptorProxyListener/
methodExecuted(InterceptorProxyListener.as:57)
at
asmock.generated::IUrlRequestLoaderProxy79C2AB0937CBA43E58B444B96F870B96EC4184FE/
sendRequest
**[ at com.hp.console.cmd.social::SocialAgentCmdHP/
authenticateSession(SocialAgentCmdHP.as:27) ]
**[ at com.hp.console.cmd.social::SocialAgentCmdHPTest/
shouldSendHttpRequestWhenAuthenticationSession(SocialAgentCmdHPTest.as:
54) ]
at Function/http://adobe.com/AS3/2006/builtin::apply
at flex.lang.reflect::Method/apply(Method.as:208)
at ReflectiveCallable/run(FrameworkMethod.as:297)
at org.flexunit.runners.model::FrameworkMethod/
applyExplosivelyAsync(FrameworkMethod.as:171)
at org.flexunit.runners.model::FrameworkMethod/
invokeExplosivelyAsync(FrameworkMethod.as:186)
at org.flexunit.internals.runners.statements::InvokeMethod/
evaluate(InvokeMethod.as:77)
at org.flexunit.internals.runners.statements::StackAndFrameManagement/
handleTimerComplete(StackAndFrameManagement.as:141)
at flash.events::EventDispatcher/dispatchEventFunction
at flash.events::EventDispatcher/dispatchEvent
at flash.utils::Timer/tick


However when I move the [Mock] meta data up like so (and using the
'mock' method) my test now looks like this and it passes:

package com.hp.console.cmd.social
{
import com.hp.console.msg.InvalidSessionMsg;
import com.hp.console.util.IFacebookSessionProxy;

import org.flexunit.asserts.assertTrue;

import org.mockito.Mockito;
import org.mockito.integrations.*;

[Mock(type="com.hp.console.util.IFacebookSessionProxy")]
[RunWith("org.mockito.integrations.flexunit4.MockitoClassRunner")]
public class SocialAgentCmdFBTest
{
public function SocialAgentCmdFBTest()
{
}


public var mockFbSession:IFacebookSessionProxy;

private var _fbCmd:SocialAgentCmdFB;

[Before]
public function setup():void
{
_fbCmd = new SocialAgentCmdFB();
}

[Test]
public function shouldAbleToCreateSesisonAndLoadLogginUser():void
{
mockFbSession = mock(IFacebookSessionProxy);
_fbCmd.fbsession = mockFbSession;

var params:Object = new Object();
params.fb_sig_ss = "ss";

_fbCmd.assignFaceBookSession(params);
verify().that(mockFbSession.createFbSession(params));

}

}
}

Kris

unread,
Jun 12, 2010, 4:05:32 AM6/12/10
to mockit...@googlegroups.com
Hi,

Yeah that's a known issue. Please assign mocks in a [Before] manually with mock(Class) function. There is an issue with auto-assign. You can read about it in the mailing list archive.

Regards,
Kris


--
You received this message because you are subscribed to the Google Groups "mockito-flex" group.
To post to this group, send email to mockit...@googlegroups.com.
To unsubscribe from this group, send email to mockito-flex...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mockito-flex?hl=en.


grep

unread,
Jun 12, 2010, 6:19:43 PM6/12/10
to mockito-flex
Thanks for that. Any idea will be fix in the next release?
> > mockito-flex...@googlegroups.com<mockito-flex%2Bunsubscribe@google groups.com>
> > .

Kris

unread,
Jun 13, 2010, 1:23:11 PM6/13/10
to mockit...@googlegroups.com
FYI a fix is in place. Let me know if it works for you.

Cheers,
Kris

To unsubscribe from this group, send email to mockito-flex...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages