Unable to setup JUnit Test

28 views
Skip to first unread message

fred...@gmail.com

unread,
Feb 28, 2007, 11:12:04 AM2/28/07
to Google Web Toolkit
Hi! I followed the guide to setup a Junit test but I'm unable to get
it working. I've searched in the issue tracker and mailing lists with
no luck. Here is my problem:

I launch the test in projects directory with:

java -Dgwt.args="-out www-test" -cp "./src:./test:./bin:/home/frede/
devel/libs/junit/junit-4.2.jar:/home/frede/devel/libs/gwt-linux-1.3.3/
gwt-user.jar:/home/frede/devel/libs/gwt-linux-1.3.3/gwt-dev-linux.jar"
junit.textui.TestRunner edu.upc.ladybird.hmi.test.Test

But all I get is this nice exception:
---------------------
.Rebinding edu.upc.ladybird.hmi.test.Test
Checking rule <generate-with
class='com.google.gwt.junit.rebind.JUnitTestCaseStubGenerator'/>
[ERROR] Unable to find type 'edu.upc.ladybird.hmi.test.Test'
[ERROR] Hint: Previous compiler errors may have made this
type unavailable
[ERROR] Deferred binding failed for 'edu.upc.ladybird.hmi.test.Test';
expect subsequent failures
com.google.gwt.core.ext.UnableToCompleteException: (see previous log
entries)
at
com.google.gwt.dev.cfg.ConditionWhenTypeAssignableTo.doEval(ConditionWhenTypeAssignableTo.java:
52)
at com.google.gwt.dev.cfg.Condition.isTrue(Condition.java:36)
at
com.google.gwt.dev.cfg.ConditionAll.doEval(ConditionAll.java:37)
at com.google.gwt.dev.cfg.Condition.isTrue(Condition.java:36)
at com.google.gwt.dev.cfg.Rule.isApplicable(Rule.java:35)
at com.google.gwt.dev.shell.StandardRebindOracle
$Rebinder.tryRebind(StandardRebindOracle.java:107)
at com.google.gwt.dev.shell.StandardRebindOracle
$Rebinder.rebind(StandardRebindOracle.java:62)
at
com.google.gwt.dev.shell.StandardRebindOracle.rebind(StandardRebindOracle.java:
170)
at
com.google.gwt.dev.shell.ShellModuleSpaceHost.rebind(ShellModuleSpaceHost.java:
122)
at
com.google.gwt.dev.shell.ModuleSpace.rebind(ModuleSpace.java:231)
at
com.google.gwt.dev.shell.ModuleSpace.rebindAndCreate(ModuleSpace.java:
171)
at
com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:135)
at
com.google.gwt.dev.shell.BrowserWidget.attachModuleSpace(BrowserWidget.java:
313)
at com.google.gwt.dev.shell.moz.BrowserWidgetMoz.access
$100(BrowserWidgetMoz.java:35)
at com.google.gwt.dev.shell.moz.BrowserWidgetMoz
$ExternalObjectImpl.gwtOnLoad(BrowserWidgetMoz.java:53)
at
org.eclipse.swt.internal.gtk.OS._g_main_context_iteration(Native
Method)
at
org.eclipse.swt.internal.gtk.OS.g_main_context_iteration(OS.java:1428)
at
org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2840)
at com.google.gwt.dev.GWTShell.pumpEventLoop(GWTShell.java:
657)
at com.google.gwt.junit.JUnitShell.runTestImpl(JUnitShell.java:
337)
at com.google.gwt.junit.JUnitShell.runTest(JUnitShell.java:
120)
at
com.google.gwt.junit.client.GWTTestCase.runTest(GWTTestCase.java:177)
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:114)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at junit.framework.TestSuite.run(TestSuite.java:227)
at junit.textui.TestRunner.doRun(TestRunner.java:116)
at junit.textui.TestRunner.start(TestRunner.java:180)
at junit.textui.TestRunner.main(TestRunner.java:138)
[ERROR] Unable to load module entry point class
edu.upc.ladybird.hmi.test.Test
com.google.gwt.core.ext.UnableToCompleteException: (see previous log
entries)
at
com.google.gwt.dev.shell.ModuleSpace.rebind(ModuleSpace.java:241)
at
com.google.gwt.dev.shell.ModuleSpace.rebindAndCreate(ModuleSpace.java:
171)
at
com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:135)
at
com.google.gwt.dev.shell.BrowserWidget.attachModuleSpace(BrowserWidget.java:
313)
at com.google.gwt.dev.shell.moz.BrowserWidgetMoz.access
$100(BrowserWidgetMoz.java:35)
at com.google.gwt.dev.shell.moz.BrowserWidgetMoz
$ExternalObjectImpl.gwtOnLoad(BrowserWidgetMoz.java:53)
at
org.eclipse.swt.internal.gtk.OS._g_main_context_iteration(Native
Method)
at
org.eclipse.swt.internal.gtk.OS.g_main_context_iteration(OS.java:1428)
at
org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2840)
at com.google.gwt.dev.GWTShell.pumpEventLoop(GWTShell.java:
657)
at com.google.gwt.junit.JUnitShell.runTestImpl(JUnitShell.java:
337)
at com.google.gwt.junit.JUnitShell.runTest(JUnitShell.java:
120)
at
com.google.gwt.junit.client.GWTTestCase.runTest(GWTTestCase.java:177)
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:114)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at junit.framework.TestSuite.run(TestSuite.java:227)
at junit.textui.TestRunner.doRun(TestRunner.java:116)
at junit.textui.TestRunner.start(TestRunner.java:180)
at junit.textui.TestRunner.main(TestRunner.java:138)
[ERROR] Failure to load module 'edu.upc.ladybird.hmi.TestExample'
com.google.gwt.core.ext.UnableToCompleteException: (see previous log
entries)
at
com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:160)
at
com.google.gwt.dev.shell.BrowserWidget.attachModuleSpace(BrowserWidget.java:
313)
at com.google.gwt.dev.shell.moz.BrowserWidgetMoz.access
$100(BrowserWidgetMoz.java:35)
at com.google.gwt.dev.shell.moz.BrowserWidgetMoz
$ExternalObjectImpl.gwtOnLoad(BrowserWidgetMoz.java:53)
at
org.eclipse.swt.internal.gtk.OS._g_main_context_iteration(Native
Method)
at
org.eclipse.swt.internal.gtk.OS.g_main_context_iteration(OS.java:1428)
at
org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2840)
at com.google.gwt.dev.GWTShell.pumpEventLoop(GWTShell.java:
657)
at com.google.gwt.junit.JUnitShell.runTestImpl(JUnitShell.java:
337)
at com.google.gwt.junit.JUnitShell.runTest(JUnitShell.java:
120)
at
com.google.gwt.junit.client.GWTTestCase.runTest(GWTTestCase.java:177)
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:114)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at junit.framework.TestSuite.run(TestSuite.java:227)
at junit.textui.TestRunner.doRun(TestRunner.java:116)
at junit.textui.TestRunner.start(TestRunner.java:180)
at junit.textui.TestRunner.main(TestRunner.java:138)
E
Time: 23,159
There was 1 error:
1)
testSimple(edu.upc.ladybird.hmi.test.Test)com.google.gwt.junit.client.TimeoutException:
The browser did not contact the server within 20000ms.
at com.google.gwt.junit.JUnitShell.notDone(JUnitShell.java:
301)
at com.google.gwt.dev.GWTShell.pumpEventLoop(GWTShell.java:
655)
at com.google.gwt.junit.JUnitShell.runTestImpl(JUnitShell.java:
337)
at com.google.gwt.junit.JUnitShell.runTest(JUnitShell.java:
120)
at
com.google.gwt.junit.client.GWTTestCase.runTest(GWTTestCase.java:177)
at
com.google.gwt.junit.client.GWTTestCase.run(GWTTestCase.java:114)

FAILURES!!!
Tests run: 1, Failures: 0, Errors: 1
--------------------------

Test.java reads:
---------
package edu.upc.ladybird.hmi.test;
import com.google.gwt.junit.client.GWTTestCase;
public class Test extends GWTTestCase {
public String getModuleName() {
return "edu.upc.ladybird.hmi.TestExample";
}
public void testSimple() {
assertTrue(true);
}
}
----------
And TestExample.gwt.xml:
------------
<module>
<inherits name='com.google.gwt.user.User'/>
</module>
-----------

I'm using Linux and java 1.6 (it fails on 5.0 also), junit 4.2 (3.8
tested with same results) and GWT 1.3.3
Any ideas on what's going on?
Thank you!

Sandy McArthur

unread,
Feb 28, 2007, 12:36:55 PM2/28/07
to Google-We...@googlegroups.com
On 2/28/07, frid...@gmail.com <fred...@gmail.com> wrote:
>
> Hi! I followed the guide to setup a Junit test but I'm unable to get
> it working. I've searched in the issue tracker and mailing lists with
> no luck. Here is my problem:
>
> I launch the test in projects directory with:
>
> java -Dgwt.args="-out www-test" -cp "./src:./test:./bin:/home/frede/
> devel/libs/junit/junit-4.2.jar:/home/frede/devel/libs/gwt-linux-1.3.3/
> gwt-user.jar:/home/frede/devel/libs/gwt-linux-1.3.3/gwt-dev-linux.jar"
> junit.textui.TestRunner edu.upc.ladybird.hmi.test.Test

Try using JUnit 3.8.2.

JUnit 4 introduced Java 1.5 specific features that may confuse GWT as
it only supports Java 1.4 right now.

--
Sandy McArthur

"He who dares not offend cannot be honest."
- Thomas Paine

fred...@gmail.com

unread,
Feb 28, 2007, 1:14:09 PM2/28/07
to Google Web Toolkit
Thank you for your response.
Junit 3.8.2 was my first try, then I checked junit 4.2 to make sure I
was running the latest version. I'm getting the same behavior in both.
Any ideas?

Cheers

On Feb 28, 6:36 pm, "Sandy McArthur" <sandy...@gmail.com> wrote:

allioop70

unread,
Feb 28, 2007, 6:06:26 PM2/28/07
to Google Web Toolkit
I am seeing something similar. After getting over all the classpath
issues to get this to run, I am now getting the timeout exception and
the simple test case fails.

Any ideas on how to get the JUnit test to run without timing out?

Time: 32.86
[java] There was 1 error:
[java] 1)
testSimple(...web.client.test.JPASTest)com.google.gwt.junit.client.TimeoutException:


The browser did not contact the server within 20000ms.

[java] at com.google.gwt.junit.JUnitShell.notDone(JUnitShell.java:
301)
[java] at com.google.gwt.dev.GWTShell.pumpEventLoop(GWTShell.java:
655)
[java] at
com.google.gwt.junit.JUnitShell.runTestImpl(JUnitShell.java:337)
[java] at com.google.gwt.junit.JUnitShell.runTest(JUnitShell.java:
120)
[java] at
com.google.gwt.junit.client.GWTTestCase.runTest(GWTTestCase.java:177)
[java] at
com.google.gwt.junit.client.GWTTestCase.run(GWTTestCase.java:114)
[java] FAILURES!!!
[java] Tests run: 1, Failures: 0, Errors: 1

Thanks!

charlie...@gmail.com

unread,
Feb 28, 2007, 10:15:21 PM2/28/07
to Google Web Toolkit
Sometimes, if you have a lot of classes involved, tests will timeout
with this message - this is still an open issue -
http://code.google.com/p/google-web-toolkit/issues/detail?id=96.

There are several techniques to work around this:
1. Try a simple dummy test as the first method, that way browser may
contact the server under the timeout, before it has to then churn on
your more involved actual tests
2. Cut down what you test by making a test specific module
3. Edit the timeout in JUnitShell

http://groups.google.com/group/Google-Web-Toolkit/browse_thread/thread/c229e9a4b67fa2bd

JUnitShell is set to 20 seconds -
http://google-web-toolkit.googlecode.com/svn/trunk/user/src/com/google/gwt/junit/

On Feb 28, 11:12 am, "frider...@gmail.com" <freder...@gmail.com>
wrote:

dominik_steiner

unread,
Mar 1, 2007, 2:56:34 AM3/1/07
to Google Web Toolkit
Hi there,

I experienced similar problems. When you look into the source code
where the TimeoutException is actually thrown it tells following

// Set a timeout period to automatically fail if the servlet hasn't
been
// contacted; something probably went wrong (the module failed to
load?)

So what I already complained about is that when this exception is
thrown you actually don't know what was the problem. The easiest way
to get a test up and running was for me with the junitCreator.cmd. I
would recommend doing what charlie.collins suggested.

HTH

Dominik

On 1 Mrz., 04:15, "charlie.coll...@gmail.com"


<charlie.coll...@gmail.com> wrote:
> Sometimes, if you have a lot of classes involved, tests will timeout

> with this message - this is still an open issue -http://code.google.com/p/google-web-toolkit/issues/detail?id=96.


>
> There are several techniques to work around this:
> 1. Try a simple dummy test as the first method, that way browser may
> contact the server under the timeout, before it has to then churn on
> your more involved actual tests
> 2. Cut down what you test by making a test specific module
> 3. Edit the timeout in JUnitShell
>

> http://groups.google.com/group/Google-Web-Toolkit/browse_thread/threa...
>
> JUnitShell is set to 20 seconds -http://google-web-toolkit.googlecode.com/svn/trunk/user/src/com/googl...

charlie...@gmail.com

unread,
Mar 1, 2007, 9:37:35 AM3/1/07
to Google Web Toolkit
Sorry about this, but I noticed after my post that your test is
already trivial, and you do appear to already have a test specific
module. In that case I would follow Dominik's advice and use
JUnitCreator, and then - if that works, or has a different problem -
you will at least have some progress.

On Mar 1, 2:56 am, "dominik_steiner" <Dominik.Stei...@partner.bmw-

fred...@gmail.com

unread,
Mar 1, 2007, 9:59:53 AM3/1/07
to Google Web Toolkit
Here is how I reproduce the failure. I've checked it both in windows
and linux.
Here is the linux script. Please change exports to appropiate
directories and run in a sandbox directory. Am I missing something?
----- init script ------

#!/bin/bash
export GWT_HOME=/home/frede/devel/libs/gwt-linux-1.3.3/
export JUNIT_JAR=/home/frede/devel/libs/junit/junit.jar
mkdir test
cd test
${GWT_HOME}/applicationCreator com.client.Hello
${GWT_HOME}/junitCreator -junit ${JUNIT_JAR} -module com.Hello
com.test.TestHello
mkdir bin
javac -d bin src/com/client/Hello.java -classpath "${GWT_HOME}/gwt-
user.jar"
javac -d bin test/com/test/TestHello.java -classpath "${GWT_HOME}/gwt-
user.jar:${JUNIT_JAR}"
./TestHello-hosted

----- end script ------

Cheers

On Mar 1, 3:37 pm, "charlie.coll...@gmail.com"

> ...
>
> read more »

charlie...@gmail.com

unread,
Mar 2, 2007, 8:20:52 PM3/2/07
to Google Web Toolkit
Ok, I know what is up after looking more carefully at that test
script. Your test package is not in the "source-path" of the module.
This is key, if you put your tests in a package other than
"client" (which is the *default* and *implicit* source path) then they
wont be found by the GWTCompiler.

Add this to the Hello.gwt.xml file:
<source path="client" />
<source path="test" />

Or, change com.test.TestHello to com.client.TestHello.

> ...
>
> read more »

fred...@gmail.com

unread,
Mar 3, 2007, 12:32:26 PM3/3/07
to Google Web Toolkit
That did the trick!
Following script runs fine

----- init script ------

#!/bin/bash
# Change the directories!


export GWT_HOME=/home/frede/devel/libs/gwt-linux-1.3.3/
export JUNIT_JAR=/home/frede/devel/libs/junit/junit.jar
mkdir test
cd test
${GWT_HOME}/applicationCreator com.client.Hello
${GWT_HOME}/junitCreator -junit ${JUNIT_JAR} -module com.Hello

com.client.TestHello


mkdir bin
javac -d bin src/com/client/Hello.java -classpath "${GWT_HOME}/gwt-
user.jar"

javac -d bin test/com/client/TestHello.java -classpath "${GWT_HOME}/


gwt-
user.jar:${JUNIT_JAR}"
./TestHello-hosted

----- end script ------

Thank you very much.

Reply all
Reply to author
Forward
0 new messages