Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GWT Mockito integration

I'm trying to set up and use Mockito into a GWT project, and I'm having trouble using it on the client side (in javascript). I tried to add a module and include Mockito, but it seems not to work (lots of errors). I also tried to do a full checkout from svn and integrate GWT in it that way, the same errors. How should this be done? Thanks.

like image 597
Eugen Avatar asked Sep 18 '09 09:09

Eugen


2 Answers

GWT code tested with mocking framework (like Mockito) runs in JVM and no compiling to JavaScript, obviously. Thus, any JavaScript-related implementations should be mocked or stubbed using mock objects.

One architecture that receives wide adoption in GWT and that simplifies testing is MVP (variation of MVC). MVP places majority of meaningful functionality inside classes called presenters. Presenters do not rely upon GWT implementation classes but instead depend on GWT interfaces (mostly). Then Mockito is applied to mock/stub those interfaces to unit test presenter classes.

This blog is full of examples on both MVP in GWT and testing with mock objects (EasyMock).

like image 187
topchef Avatar answered Nov 02 '22 08:11

topchef


And now there is https://github.com/google/gwtmockito which is probably what you need.

like image 23
Mike Avatar answered Nov 02 '22 08:11

Mike