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

时间:2010-12-28 23:59:43

标签: 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);
    }
}

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

initializationError0
java.lang.NoClassDefFoundError: com/google/gwt/dev/cfg/Condition

我google了一下,发现我需要在我的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?

2 个答案:

答案 0 :(得分:6)

在Eclipse中的Run Configurations下查看,然后查看Arguments标签。 如果移动了类,Eclipse将不会更新命令行参数。

答案 1 :(得分:0)

如果您从启动文件运行测试,则可能需要将模块包含在启动类路径中,例如:

<listAttribute key="org.eclipse.jdt.launching.CLASSPATH">
    <listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#13;&#10;&lt;runtimeClasspathEntry path=&quot;3&quot; projectName=&quot;Sample&quot; type=&quot;1&quot;/&gt;&#13;&#10;"/>
</listAttribute>