I remember testing this approach when playing around with the GWT Maps
API,
(the GWT specific API for Google Maps), and it didn´t work very well.
It seems like you run into trouble when testing complex Widgets that
make calls to other widgets.
I was using Jmock, not EasyMock, but it should be pretty much the
same.

@Test
        public void testPresenter() {
                final MapDisplayWidget widget = context.mock
(MapDisplayWidget.class);
                final MapWidget map = context.mock(MapWidget.class);
                MapData data = new MapData();
                HandlerManager eventBus = new HandlerManager(null);

                context.checking(new Expectations() {{
                        final Sequence seq = context.sequence("test");
                        oneOf(widget).getMap();inSequence(seq);
                }});

                MapDisplayPresenter presenter = new MapDisplayPresenter
(widget,data,eventBus);
        }

Doing this a get an UnsatisfiedLinkError from
com.google.gwt.maps.client.overlay.Overlay...

However, the problem here is that i couldn´t see any resonable way to
access the MapWidgets functions
without returning the entire widget from the interface.


On 19 Aug, 16:09, davis <[email protected]> wrote:
> > If your view interface return a TextBox you can't test the presenter with
> > JUnit, you will need to use GWTTestCase.
>
> Sure you can:
>
> import static org.easymock.classextension.EasyMock.*;
> import com.google.gwt.user.client.ui.TextBox;
>
> public class SomePresenterTestCase {
>
>    private MyPresenter presenter;
>    private MyView view;
>
>   �...@test
>    public void testSomething() {
>        TextBox mockBox = createMock(TextBox.class);
>        MyView mockView = createMock(MyView.class);
>        presenter = new MyPresenter(mockView);
>        expect(mockView.getSomeTextBox()).andReturn(mockBox);
>        replay(mockView);
>        replay(mockBox);
>        TextBox box = presenter.getDisplay().getSomeTextBox();
>        verify(mockView);
>    }
>
>
>
> }
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to