Problem using junitCreator

9 views
Skip to first unread message

Chris

unread,
Jun 30, 2009, 11:19:43 AM6/30/09
to Google Web Toolkit
Hi

I'm trying to add a JUnit test suite using the junitCreator script,
but am having problems. I have followed the instructions at (http://
code.google.com/webtoolkit/tutorials/1.6/JUnit.html).

Here's what I run from the project's directory (i.e., the one
containing the src and war directories):

junitCreator -junit "/Applications/eclipse/plugins/
org.junit_3.8.2.v20080602-1318/junit.jar" -module com.piconmat -
eclipse piconmat com.piconmat.client.PiconmatTest

The script runs and says:

Created directory /Users/cjr/Work/Eclipse Workspace/piconmat/test
Created directory /Users/cjr/Work/Eclipse Workspace/piconmat/test/com/
piconmat/client
Created file /Users/cjr/Work/Eclipse Workspace/piconmat/test/com/
piconmat/client/PiconmatTest.java
Created file /Users/cjr/Work/Eclipse Workspace/piconmat/PiconmatTest-
hosted.launch
Created file /Users/cjr/Work/Eclipse Workspace/piconmat/PiconmatTest-
web.launch
Created file /Users/cjr/Work/Eclipse Workspace/piconmat/PiconmatTest-
hosted
Created file /Users/cjr/Work/Eclipse Workspace/piconmat/PiconmatTest-
web

If I then refresh my project in Eclipse, I see the new test directory
at the same level as src, war etc., displayed as a hierarchy of
directories (rather than a package, as I'd imagine—and Eclipse is
obviously not compiling the test class for me, also as I'd expect); I
also see the various launch scripts etc.

If I run the PiconmatTest-hosted script, I get a "Class not found
"com.piconmat.client.PiconmatTest" error—presumably because the java
file has not been compiled.

If I look at the Run Configurations, and select one of the generated
configurations, the Run button is greyed out.

If I run junitCreator within the src directory, as:

junitCreator -junit "/Applications/eclipse/plugins/
org.junit_3.8.2.v20080602-1318/junit.jar" -module com.piconmat -
eclipse piconmat com.piconmat.client.PiconmatTest

then after refreshing the project in Eclipse I get a new
test.com.piconmat.client package, but the following compile errors:

The project was not built since its build path is incomplete. Cannot
find the class file for junit.framework.TestCase. Fix the build path
then try building this project
The type junit.framework.TestCase cannot be resolved. It is indirectly
referenced from required .class files

I'm sure there's something simple that I'm not doing, and would really
appreciate someone telling me what that is!

Thanks in advance

Chris

Isaac Truett

unread,
Jun 30, 2009, 5:18:26 PM6/30/09
to Google-We...@googlegroups.com
> If I run the PiconmatTest-hosted script, I get a "Class not found
> "com.piconmat.client.PiconmatTest" error—presumably because the java
> file has not been compiled.

Exactly. It's not compiled. Add "test" as a source folder
(Project>Properties>Java Build Path>Source).

> The project was not built since its build path is incomplete. Cannot
> find the class file for junit.framework.TestCase. Fix the build path
> then try building this project
> The type junit.framework.TestCase cannot be resolved. It is indirectly
> referenced from required .class files
>

You need to add junit.jar to your classpath (Project>Properties>Java
Build Path>Libraries).

Chris

unread,
Jul 1, 2009, 7:34:00 AM7/1/09
to Google Web Toolkit
Thanks Isaac, much appreciated.

Just to clarify (for anyone searching for this in the future!), what I
had to do was:

1. From the top-level directory (i.e., the one containing the src and
war directories), do:

junitCreator -junit "/Applications/eclipse/plugins/
org.junit_3.8.2.v20080602-1318/junit.jar" -module
com.piconmat.Piconmat -eclipse piconmat
com.piconmat.client.PiconmatTest

2. Refresh Eclipse's Package Explorer.
3. Add "test" as a source folder (Project>Properties>Java Build
Path>Source).
4. Add junit.jar to your classpath (Project>Properties>Java Build
Path>Libraries).
5. Run the test suite (Run>Run Configurations… then select
JUnit>PiconmatTest-hosted, then Run).

Reply all
Reply to author
Forward
0 new messages