Open cushon opened 9 years ago
Yeah, the fact that we call GWT.create to populate UiFields will be problematic. We probably don't need to do this though - we could instead provide some sort of back door to invoke the underlying create code directly with additional type information. Would take some experimenting to figure out if we have the necessary information available and how to get it into Mockito.
The implementation of
FakeUiBinderProvider
erases the type of all of the fields it injects (e.g.Box<String>
gets mocked asBox<Object>
). It isn't possible to pass the necessary type information throughGWT.create()
(since it only takes a class literal), but there may be alternatives I'm missing.Here's an example:
The mock for
myWidget.message
will be a rawBox
, soget()
returns aString
, causing aClassCastException
:I encountered this because if you write:
Then the eclipse compiler will generate a string cast on the result of
myWidget.message.get()
, which causes the test to crash. (javac is unaffected, except for specific versions of javac9.)Here's the complete repro: