gwt 测试:无法在类路径上找到sample.gwt.xml
我正在为我的应用程序运行 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
我用谷歌搜索了一下,发现我需要在我的pom中包含gwt-dev,我这样做了,再次运行测试,现在它抛出了错误:
[错误] 无法在类路径上找到“Sample.gwt.xml”;可能是拼写错误,或者您可能忘记包含源代码的类路径条目?
I'm running gwt test for my application, it's like a 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我发现 Eclipse 的
Run Configuration
Classpath
选项卡对我有用。您可能已经有一个条目,例如
java - appnameis/src/main/
这似乎是一个毫无意义的黑客,但以下内容对我有用
按绿色“播放”按钮 >
运行配置
>Classpath
选项卡选择一个
用户条目
,例如java - appnameis/src/main/
选择
Advanced
按钮选择
添加文件夹
深入了解
appnameis/src/main/java/app/name
OK
您现在拥有如下条目:
java - appnameis/src/main/
is - appnameis/src/main/java/app/name
其中您的
appnameis.gwt.xml
文件直接位于is
文件夹Run
下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
tabSelect one of the
User Entries
e.g.java - appnameis/src/main/
Select the
Advanced
buttonSelect
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 theis
folderRun
检查 Eclipse 中的
Run Configurations
下的内容,然后检查Arguments
选项卡。如果类被移动,Eclipse 将不会更新命令行参数。
Check under
Run Configurations
in Eclipse, and check theArguments
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: