com.gwtplatform.tester
Class MockingBinder<U,O>

java.lang.Object
  extended by com.gwtplatform.tester.MockingBinder<U,O>
Type Parameters:
U - Mock type returned by UiBinder.createAndBindUi(Object).
O - Owner type.
All Implemented Interfaces:
UiBinder<U,O>

public abstract class MockingBinder<U,O>
extends Object
implements UiBinder<U,O>

MockingBinder makes testing view even easier by mocking every UiField and returning a mocked object upon creation.

To use it, you should build a small class that extends MockingBinder and bind that class inside your Guice test module. You will have to provide a MockFactory to let MockingBinder mock everything. Ex:

 public static class Module extends JukitoModule {
  static class MyTestBinder extends MockingBinder<Widget, BlogView> implements
  Binder {
    public MyTestBinder(final AnyMockFactory anyMockFactory) {
      super(Widget.class, anyMockFactory);
    }
  }

  protected void configureTest() {
    GWTMockUtilities.disarm();

    bind(Binder.class).to(MyTestBinder.class);
  }
 }
 
Disarming GWT is important to unit test views.

Author:
Christian Goudreau

Constructor Summary
MockingBinder(Class<U> returnTypeClass, MockFactory mockFactory)
           
 
Method Summary
 U createAndBindUi(O owner)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MockingBinder

public MockingBinder(Class<U> returnTypeClass,
                     MockFactory mockFactory)
Parameters:
returnTypeClass - Type to return when creating the mocked ui.
mockFactory - A MockFactory to provide mock object.
Method Detail

createAndBindUi

public U createAndBindUi(O owner)
                  throws IllegalArgumentException
Specified by:
createAndBindUi in interface UiBinder<U,O>
Throws:
IllegalArgumentException


Copyright © 2010-2011 ArcBees. All Rights Reserved.