2012-07-12 52 views
4

看看这张图片。 Mockito验证论据是怎么回事?为什么mockito返回错误前夕参数是相同的?

我想验证视图是由参数工厂调用的。

@Test 
    public void shouldInitializeTheDriverWithTheRequestFactory() { 

    CVProxy proxy = context.create(CVProxy.class); 

    workflow.initialize(); 

    verify(view).initializeWithRequestFactory(factory); 

    verify(view).editWithEditor(proxy, context); 

    } 

但是,我得到这个错误是奇怪的!

Argument(s) are different! Wanted: 
view.initializeWithRequestFactory(
    c[email protected]13c6a22 
); 
-> at CreatingNewCVWorkflowTest.shouldInitializeTheDriverWithTheRequestFactory(CreatingNewCVWorkflowTest.java:53) 
Actual invocation has different arguments: 
view.initializeWithRequestFactory(
    c[email protected]13c6a22 
); 

因为你可以参数是相同的。 enter image description here

回答

5

有可能工厂实例有一个不正确实现的equals方法(以便equals方法报告该对象不等于自己)?

+0

as google ...:D – Adelin 2012-07-12 13:10:59

+0

我在想同样的事情。 – jhericks 2012-07-12 16:07:56

+0

无论是它还是其超类 - ['AbstractRequestFactory'](http://code.google.com/p/google-web-toolkit/source/browse/trunk/user/src/com/google/web/bindery/ requestfactory/shared/impl/AbstractRequestFactory.java)和['IdFactory'](http://code.google.com/p/google-web-toolkit/source/browse/trunk/user/src/com/google/web /bindery/requestfactory/shared/impl/IdFactory.java)--实现'equals'。 – 2012-07-26 15:39:19

相关问题