infinite / mockito-flex

0 stars 0 forks source link

Unexpected behaviour with getters #7

Closed infinite closed 10 years ago

infinite commented 10 years ago

I am writing unit tests for a logging framework and wanted to use Mockito for integration tests. Unfortunatly it somewhy exits with a exception that I can't really understand:

Here is the simplified version: {{{ var logTarget: ILogger = ILogger( _mockito.mock( ILogger ) );

_mockito.given( logTarget.debugEnabled ).willReturn(true); logTarget.debugEnabled; _mockito.verify().that( logTarget.debugEnabled );

_mockito.given( logTarget.warnEnabled ).willReturn(true); logTarget.warnEnabled; _mockito.verify().that( logTarget.warnEnabled ); }}}

Now i get a error thrown at the 2nd verification that logTarget.warnEnabled was called twice????

Here is the unambigtious error:

{{{ org.as3commons.logging::LogTest.testlogNormally Error: Wanted (1) but invoked (2): get at org.mockito.impl::Times/verify()[C:\dev\mockito-flex\mockito\src\main\flex\org\mockito\impl\Times.as:63] at org.mockito.impl::MockInterceptorImpl/methodCalled()[C:\dev\mockito-flex\mockito\src\main\flex\org\mockito\impl\MockInterceptorImpl.as:56] at org.mockito.impl::AsmockMockery/methodCall()[C:\dev\mockito-flex\mockito\src\main\flex\org\mockito\impl\AsmockMockery.as:81] at ASMockInterceptor/intercept() at asmock.framework.proxy::InterceptorProxyListener/methodExecuted() at asmock.generated::ILoggerC0503344C841AADD2C0BE872365FC48B17939521/get warnEnabled() at org.as3commons.logging::LogTest/testlogNormally()[D:\Work\Martin\workspace\as3-commons-logging\src\test\actionscript\org\as3commons\logging\LogTest.as:55] at Function/http://adobe.com/AS3/2006/builtin::apply() at flex.lang.reflect::Method/apply()[C:\Users\mlabriola\Documents\workspaces\net\digitalprimates\opensource\branches\4.x\FlexUnit4\src\flex\lang\reflect\Method.as:124] at ReflectiveCallable/run()[C:\Users\mlabriola\Documents\workspaces\net\digitalprimates\opensource\branches\4.x\FlexUnit4\src\org\flexunit\runners\model\FrameworkMethod.as:214] at org.flexunit.runners.model::FrameworkMethod/applyExplosivelyAsync()[C:\Users\mlabriola\Documents\workspaces\net\digitalprimates\opensource\branches\4.x\FlexUnit4\src\org\flexunit\runners\model\FrameworkMethod.as:121] at org.flexunit.runners.model::FrameworkMethod/invokeExplosivelyAsync()[C:\Users\mlabriola\Documents\workspaces\net\digitalprimates\opensource\branches\4.x\FlexUnit4\src\org\flexunit\runners\model\FrameworkMethod.as:132] at org.flexunit.internals.runners.statements::InvokeMethod/evaluate()[C:\Users\mlabriola\Documents\workspaces\net\digitalprimates\opensource\branches\4.x\FlexUnit4\src\org\flexunit\internals\runners\statements\InvokeMethod.as:52] at org.flexunit.internals.runners.statements::StackAndFrameManagement/handleTimerComplete()[C:\Users\mlabriola\Documents\workspaces\net\digitalprimates\opensource\branches\4.x\FlexUnit4\src\org\flexunit\internals\runners\statements\StackAndFrameManagement.as:100] at flash.events::EventDispatcher/dispatchEventFunction() at flash.events::EventDispatcher/dispatchEvent() at flash.utils::Timer/tick(); }}}

infinite commented 10 years ago

From loomis on 2009-07-31 08:50:12+00:00

Hi Martin,

Seems like a good catch. Try attached patch and let me know.

Regards, Kris

infinite commented 10 years ago

From martinheidegger on 2009-07-31 09:43:52+00:00

Will try tonight.

cheers Martin.

infinite commented 10 years ago

From martinheidegger on 2009-07-31 19:26:05+00:00

Seems to do the trick, thanks