Try to avoid the use of GWTTestCase.
I spend hours in it and it's very fragile and unfriendly.
Try to develop your code such that you can unit test it without GWT
like explained here:
See the links (especially the last one) in issue  6113:
http://code.google.com/p/google-web-toolkit/issues/detail?id=6113

I hope it helps
- Ed

On Oct 28, 6:50 pm, laredotornado <laredotorn...@zipmail.com> wrote:
> Hi,
>
> I'm using GWT 2.4 with JUnit 4.8.1.  I want to simulate clicking on a
> button on my page.  When I run the app normally, I can easily click on
> the button.  Here's how I reference it in my module EntryPoint
> class ...
>
>         public void onModuleLoad() {
>                 final com.google.gwt.dom.client.Element submitElement =
> Document.get().getElementById(SUBMIT_BUTTON_ID);
>                 final Button submitButton = Button.wrap(submitElement);
>
> However, when I run my GWTTestCase, the "submitElement" field above is
> null.  Any ideas how I can change my test case to set this up
> correctly?  Right now my test case consists of ...
>
> public class GetHtmlTest extends GWTTestCase {
>
>         ...
>
>         @Override
>         public String getModuleName() {
>                 return "com.myco.clearing.productplus.Productplus_gwt";
>         }
>
>         public void prepareTests() {
>                 productPlusModule = new Productplus_gwt();
>                 productPlusModule.onModuleLoad();
>                 nameField =
> TextBox.wrap(Document.get().getElementById(Productplus_gwt.NAME_FIELD_ID));
>                 submitButton =
> Button.wrap(Document.get().getElementById(Productplus_gwt.SUBMIT_BUTTON_ID) );
>
>         } // prepareTests
>
>         @Test
>         public void testSuccessEvent() {
>                 prepareTests();
>
> Here's the exact exception and stack trace.  I have this GWT project
> set up in Eclipse Indigo, and run it by click-clicking my test case
> and select "Run As" -> "GWT Junit Test".
>
> java.lang.RuntimeException: Remote test failed at 10.40.70.197 /
> Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.19) Gecko/
> 2010031422 Firefox/3.0.19
>         at com.google.gwt.junit.JUnitShell.processTestResult(JUnitShell.java:
> 1288)
>         at com.google.gwt.junit.JUnitShell.runTestImpl(JUnitShell.java:1408)
>         at com.google.gwt.junit.JUnitShell.runTestImpl(JUnitShell.java:1309)
>         at com.google.gwt.junit.JUnitShell.runTest(JUnitShell.java:653)
>         at com.google.gwt.junit.client.GWTTestCase.runTest(GWTTestCase.java:
> 441)
>         at junit.framework.TestCase.runBare(TestCase.java:134)
>         at junit.framework.TestResult$1.protect(TestResult.java:110)
>         at junit.framework.TestResult.runProtected(TestResult.java:128)
>         at junit.framework.TestResult.run(TestResult.java:113)
>         at junit.framework.TestCase.run(TestCase.java:124)
>         at com.google.gwt.junit.client.GWTTestCase.run(GWTTestCase.java:296)
>         at junit.framework.TestSuite.runTest(TestSuite.java:232)
>         at junit.framework.TestSuite.run(TestSuite.java:227)
>         at
> org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:
> 83)
>         at
> org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestRe 
> ference.java:
> 50)
>         at
> org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:
> 38)
>         at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestR 
> unner.java:
> 467)
>         at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestR 
> unner.java:
> 683)
>         at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner 
> .java:
> 390)
>         at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunne 
> r.java:
> 197)
> Caused by: java.lang.AssertionError: Child cannot be null
>         at com.google.gwt.dom.client.Node$.isOrHasChild$(Node.java:278)
>         at com.google.gwt.user.client.ui.Button.wrap(Button.java:55)
>         at
> com.myco.clearing.productplus.client.Productplus_gwt.onModuleLoad(Productpl 
> us_gwt.java:
> 35)
>         at
> com.myco.clearing.productplus.client.GetHtmlTest.prepareTests(GetHtmlTest.j 
> ava:
> 33)
>         at
> com.myco.clearing.productplus.client.GetHtmlTest.testSuccessEvent(GetHtmlTe 
> st.java:
> 43)
>         at
> com.myco.clearing.productplus.client.__GetHtmlTest_unitTestImpl.doRunTest(_ 
> _GetHtmlTest_unitTestImpl.java:
> 7)
>         at junit.framework.TestCase.runTest(TestCase.java:62)
>         at com.google.gwt.junit.client.GWTTestCase.runBare(GWTTestCase.java:
> 188)
>         at
> com.google.gwt.junit.client.GWTTestCase.__doRunTest(GWTTestCase.java:
> 129)
>         at com.google.gwt.junit.client.impl.GWTRunner.runTest(GWTRunner.java:
> 389)
>         at
> com.google.gwt.junit.client.impl.GWTRunner.doRunTest(GWTRunner.java:
> 318)
>         at com.google.gwt.junit.client.impl.GWTRunner.access$9(GWTRunner.java:
> 312)
>         at com.google.gwt.junit.client.impl.GWTRunner
> $TestBlockListener.onSuccess(GWTRunner.java:107)
>         at com.google.gwt.junit.client.impl.GWTRunner
> $InitialResponseListener.onSuccess(GWTRunner.java:63)
>         at com.google.gwt.junit.client.impl.GWTRunner
> $InitialResponseListener.onSuccess(GWTRunner.java:1)
>         at
> com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter.onResponseReceiv 
> ed(RequestCallbackAdapter.java:
> 232)
>         at
> com.google.gwt.http.client.Request.fireOnResponseReceived(Request.java:
> 287)
>         at com.google.gwt.http.client.RequestBuilder
> $1.onReadyStateChange(RequestBuilder.java:395)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
> 39)
>         at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImp 
> l.java:
> 25)
>         at java.lang.reflect.Method.invoke(Method.java:597)
>         at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:
> 103)
>         at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:
> 71)
>         at
> com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.jav a:
> 172)
>         at
> com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingFo 
> rReturn(BrowserChannelServer.java:
> 337)
>         at
> com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChann 
> elServer.java:
> 218)
>         at
> com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:
> 136)
>         at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:
> 561)
>         at
> com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:
> 269)
>         at
> com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.j 
> ava:
> 91)
>         at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
>         at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:220)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
> 39)
>         at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImp 
> l.java:
> 25)
>         at java.lang.reflect.Method.invoke(Method.java:597)
>         at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:
> 103)
>         at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:
> 71)
>         at
> com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.jav a:
> 172)
>         at
> com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChanne 
> lServer.java:
> 292)
>         at
> com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChan 
> nelServer.java:
> 546)
>         at
> com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java :
> 363)
>         at java.lang.Thread.run(Thread.java:662)
>
> Thanks, - Dave

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to