2012-05-23 79 views
2

我写使用GWTTestCase简单的测试,这里是:GWTTestCase给了我一个错误

public class SampleTest extends GWTTestCase { 

    @Override 
    public String getModuleName() { 
     return "path.to.my.one.and.only.Module"; 
    } 

    public void testSome() { 
     assertNotNull(null); 
    } 
} 

但是当我运行MVN测试,测试失败,下一个错误:

[ERROR] Unable to find type 'java.lang.Object' 
    [ERROR] Hint: Check that your module inherits 'com.google.gwt.core.Core' either directly or indirectly (most often by inheriting module 'com.google.gwt.user.User') 
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 3.648 sec <<< FAILURE! 

我有'com.google.gwt.user.User'在我的模块中。

回答

0

该错误表明您需要在gwt.xml文件中继承com.google.gwt.core.Core,并且并不是说您的类应该扩展/实现它。因为你还没有提供gwt.xml。我举了一个例子。

给这个在您的gwt.xml一试:

<?xml version="1.0" encoding="UTF-8"?> 
<!DOCTYPE 
    module 
    PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.3.0//EN" 
    "http://google-web-toolkit.googlecode.com/svn/tags/2.3.0/distro-source/core/src/gwt-module.dtd"> 

<module rename-to="hello"> 
    <inherits name="com.google.gwt.core.Core" /> 
    <source path="foo" /> <!-- Your package name --> 
</module> 
+0

是的我明白了,就像我说的,我完全有这个模块在My.gwt.xml模块中继承。 – user1289877

+0

提供更多详情。 –

+2

问题出在班上,它必须以“GwtTest”开头。所以我将类的名称更改为GwtTestSampleTest。下一个问题是我必须运行** mvn gwt:test **而不是** mvn test ** – user1289877

0

我设法解决这个问题通过固定我的JRE定义,要做到这一点去窗口>>的Java>已安装JRE>添加JRE的正确路径。你去了!