gwt test: unable to find sample.gwt.xml on your classpath
I'm running gwt test for my application, it's like a开发者_如何学Go nightmare, got problem one after another, not sure what's going wrong.
First, I created a dummy test case:
public class ListItemTest extends GWTTestCase {
/**
* Specifies a module to use when running this test case. The returned
* module must include the source for this class.
*
* @see com.google.gwt.junit.client.GWTTestCase#getModuleName()
*/
@Override
public String getModuleName() {
return "com.dyihi.services.sample.Sample";
}
/**
* Add as many tests as you like
*/
public void testSimple() {
assertTrue(true);
}
}
When I ran 'mvn test' this simple test failed. The error message is:
initializationError0
java.lang.NoClassDefFoundError: com/google/gwt/dev/cfg/Condition
I googled around and found out that I need to include gwt-dev in my pom, and I did that, ran the test again, now it threw error:
[ERROR] Unable to find 'Sample.gwt.xml' on your classpath; could be a typo, or maybe you forgot to include a classpath entry for source?
I found Eclipse's Run Configuration
Classpath
tab worked for me.
You might already have an entry like
java - appnameis/src/main/
It seems a pointless hack but the following worked for me
Press the Green "Play" button > Run configurations
> Classpath
tab
Select one of the User Entries
e.g. java - appnameis/src/main/
Select the Advanced
button
Select Add Folders
drill down to appnameis/src/main/java/app/name
OK
You now have entries like:
java - appnameis/src/main/
is - appnameis/src/main/java/app/name
Where your appnameis.gwt.xml
file is directly under the is
folder
Run
Check under Run Configurations
in Eclipse, and check the Arguments
tab.
If the class is moved, Eclipse won't update the command line arguments.
If you're running the test from a launch file you might need to include your module in the launch classpath, for example:
<listAttribute key="org.eclipse.jdt.launching.CLASSPATH">
<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry path="3" projectName="Sample" type="1"/> "/>
</listAttribute>
精彩评论