create Junit Test case for my Presentation

91 views
Skip to first unread message

Manish

unread,
Aug 29, 2011, 7:56:59 AM8/29/11
to Google Web Toolkit
I am trying to create Junit Test case for my Presentation Layer ,
while creating Presentation instance in setup method of Junit it goes
througn GWT.Create at this point it fails saying

java.lang.ExceptionInInitializerError
.
.
Caused by: java.lang.UnsupportedOperationException: ERROR:
GWT.create() is only usable in client code! It cannot be called, for
example, from server code. If you are running a unit test, check that
your test case extends GWTTestCase and that GWT.create() is not called
from within an initializer or constructor.
at com.google.gwt.core.client.GWT.create(GWT.java:91)
at com.google.gwt.user.client.ui.UIObject.<clinit>(UIObject.java:188)
... 24 more

and when I add following line to deal with GWT.Create case

@BeforeClass
public static void disarm() {
GWTMockUtilities.disarm();
}

@AfterClass
public static void rearm() {
GWTMockUtilities.restore();
}

it gives Null pointer exception .. will be thankful to any help.

Michael Vogt

unread,
Aug 29, 2011, 9:40:16 AM8/29/11
to google-we...@googlegroups.com
Hello.

> I am trying to create Junit Test case for my Presentation Layer ,
> while creating Presentation instance in setup method of Junit it goes
> througn GWT.Create at this point it fails saying
>

To test your presentation layer, you need to use GwtTestCase instead
of plain JUnit:
http://code.google.com/webtoolkit/doc/latest/DevGuideTesting.html


Hope this helps,
Michael

Reply all
Reply to author
Forward
0 new messages