2012-05-23 80 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的正確路徑。你去了!