我正在编写的测试使用AutoBeanCodex对AutoBeans进行编码和解码。当我尝试测试使用AutoBeanCodex.decode(...)的方法时,会得到以下错误:
java.lang.ClassCastException: com.google.web.bindery.autobean.shared.AutoBean$$EnhancerByMockitoWithCGLIB$$78caf05b cannot be cast to com.google.web.bindery.autobean.shared.impl.AbstractAutoBean
at com.google.web.bindery.autobean.shared.impl.AutoBeanCodexImpl.doDecode(AutoBeanCodexImpl.java:549)
at com.google.web.bindery.autobean.shared.AutoBeanCodex.decode(AutoBeanCodex.java:39)
at ...第一个问题是,如何在gwtmockito测试中处理AutoBeanCodex?
我必须使用像这样的假提供者吗,GwtMockito.useProviderForType(Class, FakeProvider)
如果有多种方法来处理AutoBeanCodex,那么最好的方法是什么?
发布于 2014-01-15 09:42:06
首先(我还没有使用GwtMockito ),您应该为AutoBeanFactory.class配置一个FakeProvider以委托给AutoBeanFactorySource.create(),这样就可以获得真正的 AutoBean实例,AutoBeanCodex应该能够序列化和反序列化。
您可能应该向GwtMockito提出一个问题,以便这种行为是内置的,就像UiBinder等人一样。
发布于 2015-01-20 11:10:37
您也可以使用powermock进行静态测试。我把它和gwtmockito一起用在了同一个测试中
https://stackoverflow.com/questions/21127936
复制相似问题