Cumbersome jUnit setup

24 views
Skip to first unread message

kito

unread,
Oct 6, 2009, 2:55:03 AM10/6/09
to Google Web Toolkit
I'm just setting up the environment for testing my GWT app with jUnit
tests.

Just some sidenotes before:
Dev environment: Eclipse on Snow Leopard
GWT version: 1.7.1 (installed with Google Eclipse Plugin)

Since - unfortunately - the Google Plugin doesn't yet have a wizard
for creating jUnit tests, I've used the jUnitCreator command line tool
for doing this.

The structure of my project (created by the GPlugin) looks like
src
com.mycompany.myappname
Myappname.gwt.xml
com.mycompany.myappname.client
...
com.mycompany.myappname.server
...

Now when I used the jUnitCreator, it was modified like
src
com.mycompany.myappname
Myappname.gwt.xml
com.mycompany.myappname.client
...
com.mycompany.myappname.server
...
test
com.mycompany.myappname.tests
MyAppnameTest.java

Beside having to fix some issues like declaring the generated test
folder to be a source folder and including the jUnit library, the
generated getModuleName inside the GWTTestcase was

public String getModuleName() {
return "com.mycompany.myappname";
}

That would be all fine, but then, when I tried to launch the test, I
got the error message
[ERROR] Unable to find 'com/mycompany/myappname.gwt.xml' on your
classpath; could be a typo, or maybe you forgot to include a classpath
entry for source?

That's weird! Why is it looking for the myappname.gwt.xml inside 'com/
mycompany' while it should look inside 'com/mycompany/myappname/'???

Someone has an idea how to fix this best, without having to mess
around with the standard project structure too much?

Thx a lot.

Thomas Broyer

unread,
Oct 6, 2009, 12:29:42 PM10/6/09
to Google Web Toolkit


On 6 oct, 08:55, kito <juri.strumpfloh...@gmail.com> wrote:
[...]
>   public String getModuleName() {
>     return "com.mycompany.myappname";
>   }
>
> That would be all fine, but then, when I tried to launch the test, I
> got the error message
> [ERROR] Unable to find 'com/mycompany/myappname.gwt.xml' on your
> classpath; could be a typo, or maybe you forgot to include a classpath
> entry for source?
>
> That's weird! Why is it looking for the myappname.gwt.xml inside 'com/
> mycompany' while it should look inside 'com/mycompany/myappname/'???

It looks for what you tell it to !!!

getModuleName should return "com.mycompany.myappname.Myappname"

Juri

unread,
Oct 6, 2009, 12:43:18 PM10/6/09
to Google Web Toolkit
Ok...sounds straightforward and I actually also tried that, but if I
change it like you mentioned and then run the sample dummy test
generated by the jUnitCreator, it will give me the following error:

com.google.gwt.junit.JUnitFatalLaunchException: The test class
'com.mycompany.myappname.MyAppnameTest' was not found in module
'com.mycompany.myappname.Myappname'; no compilation unit for that type
was seen
at com.google.gwt.junit.JUnitShell.checkTestClassInCurrentModule
(JUnitShell.java:390)
at com.google.gwt.junit.JUnitShell.runTestImpl(JUnitShell.java:626)
at com.google.gwt.junit.JUnitShell.runTest(JUnitShell.java:346)
at com.google.gwt.junit.client.GWTTestCase.runTest(GWTTestCase.java:
219)
at junit.framework.TestCase.runBare(TestCase.java:130)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:120)
at com.google.gwt.junit.client.GWTTestCase.run(GWTTestCase.java:132)
at junit.framework.TestSuite.runTest(TestSuite.java:230)
at junit.framework.TestSuite.run(TestSuite.java:225)
at
org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run
(JUnit3TestReference.java:130)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run
(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests
(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests
(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run
(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main
(RemoteTestRunner.java:197)

Thomas Broyer

unread,
Oct 6, 2009, 1:35:01 PM10/6/09
to Google Web Toolkit


On 6 oct, 18:43, Juri <juri.strumpfloh...@gmail.com> wrote:
> Ok...sounds straightforward and I actually also tried that, but if I
> change it like you mentioned and then run the sample dummy test
> generated by the jUnitCreator, it will give me the following error:
>
> com.google.gwt.junit.JUnitFatalLaunchException: The test class
> 'com.mycompany.myappname.MyAppnameTest' was not found in module
> 'com.mycompany.myappname.Myappname'; no compilation unit for that type
> was seen

Yes, you test is run in a browser (hosted mode genrally) so it must
live within the 'client' subpackage (or whichever <source path="" />
you configured in your module's gwt.xml)

Juri

unread,
Oct 14, 2009, 3:20:44 AM10/14/09
to Google Web Toolkit
Of course it has to. Damn, didn't think about that, sorry.

Thanks for your help.
Reply all
Reply to author
Forward
0 new messages