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×tamp=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));
}
}
}