gwt test:无法在类路径中找到sample.gwt.xml

use*_*587 10 java gwt classpath

我正在为我的应用程序运行gwt测试,这就像一场噩梦,一个接一个地遇到问题,不知道出了什么问题.

首先,我创建了一个虚拟测试用例:

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);
    }
}
Run Code Online (Sandbox Code Playgroud)

当我运行'mvn test'时,这个简单的测试失败了.错误消息是:

initializationError0
java.lang.NoClassDefFoundError: com/google/gwt/dev/cfg/Condition
Run Code Online (Sandbox Code Playgroud)

我搜索了一下,发现我需要在我的pom中包含gwt-dev,然后我就这样做了,再次运行测试,现在它抛出了错误:

[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?

Mos*_*she 6

检查下Run Configurations在Eclipse中,并检查Arguments标签.如果移动了类,Eclipse将不会更新命令行参数.


小智 6

我发现Eclipse的Run Configuration Classpath标签对我有用.

您可能已经有类似的条目 java - appnameis/src/main/

这似乎是一个毫无意义的黑客,但以下对我有用

按绿色"播放"按钮Run configurations>> Classpath选项卡

选择其中一个User Entries例如java - appnameis/src/main/

选择Advanced按钮

选择Add Folders 向下钻取appnameis/src/main/java/app/name OK

您现在有以下条目:

java - appnameis/src/main/

is - appnameis/src/main/java/app/name

您的appnameis.gwt.xml文件直接位于该is文件夹下

Run