java gwt 测试:无法在您的类路径中找到 sample.gwt.xml
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4550483/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
gwt test: unable to find sample.gwt.xml on your classpath
提问by user468587
I'm running gwt test for my application, it's like a nightmare, got problem one after another, not sure what's going wrong.
我正在为我的应用程序运行 gwt 测试,这就像一场噩梦,一个接一个地出现问题,不知道出了什么问题。
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:
当我运行“mvn test”时,这个简单的测试失败了。错误信息是:
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:
我搜索了一下,发现我需要在我的 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?
[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?
采纳答案by TheSolarSheriff
I found Eclipse's Run Configuration
Classpath
tab worked for me.
我发现 Eclipse 的Run Configuration
Classpath
选项卡对我有用。
You might already have an entry like
java - appnameis/src/main/
您可能已经有一个条目,例如
java - appnameis/src/main/
It seems a pointless hack but the following worked for me
这似乎是一个毫无意义的黑客,但以下对我有用
Press the Green "Play" button > Run configurations
> Classpath
tab
按绿色的“播放”按钮 > Run configurations
>Classpath
选项卡
Select one of the User Entries
e.g. java - appnameis/src/main/
选择其中之一,User Entries
例如java - appnameis/src/main/
Select the Advanced
button
选择Advanced
按钮
Select Add Folders
drill down to appnameis/src/main/java/app/name
OK
选择Add Folders
向下钻取appnameis/src/main/java/app/name
OK
You now have entries like:
您现在有以下条目:
java - appnameis/src/main/
java - appnameis/src/main/
is - appnameis/src/main/java/app/name
is - appnameis/src/main/java/app/name
Where your appnameis.gwt.xml
file is directly under the is
folder
您的appnameis.gwt.xml
文件直接位于is
文件夹下的位置
Run
Run
回答by Moshe
Check under Run Configurations
in Eclipse, and check the Arguments
tab.
If the class is moved, Eclipse won't update the command line arguments.
Run Configurations
在 Eclipse下检查,并检查Arguments
选项卡。如果类被移动,Eclipse 将不会更新命令行参数。
回答by dj18
If you're running the test from a launch file you might need to include your module in the launch classpath, for example:
如果您从启动文件运行测试,您可能需要在启动类路径中包含您的模块,例如:
<listAttribute key="org.eclipse.jdt.launching.CLASSPATH">
<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry path="3" projectName="Sample" type="1"/> "/>
</listAttribute>