gpt4 book ai didi

java - 使用 maven gwt 插件运行 GWTTestCase 时出错

转载 作者:搜寻专家 更新时间:2023-10-30 21:43:28 25 4
gpt4 key购买 nike

我创建了一个扩展 GWTTestCase 的测试,但我收到了这个错误:

mvn integration-test gwt:test
...
Running com.myproject.test.ui.GwtTestMyFirstTestCase
Translatable source found in...
[WARN] No source path entries; expect subsequent failures
[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: 2.1 sec <<< FAILURE!

GwtTestMyFirstTestCase.java 位于/src/test/java,而GWT 模块位于src/main/java。我认为这应该不是问题。

我已根据 http://mojo.codehaus.org/gwt-maven-plugin/user-guide/testing.html 完成所有要求的工作当然,我的 gwt 模块已经间接导入了 com.google.gwt.core.Core。

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.myproject</groupId>
<artifactId>main</artifactId>
<packaging>jar</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>Main Module</name>

<properties>
<gwt.module>com.myproject.MainModule</gwt.module>
</properties>

<parent>
<groupId>com.myproject</groupId>
<artifactId>app</artifactId>
<version>0.1.0-SNAPSHOT</version>
</parent>

<dependencies>

<dependency>
<groupId>com.myproject</groupId>
<artifactId>app-commons</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-dev</artifactId>
<version>${gwt.version}</version>
<scope>provided</scope>
</dependency>


</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<configuration>
<outputFile>../app/src/main/webapp/WEB-INF/main.tree</outputFile>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>


<executions>
<execution>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>

</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<classesDirectory>
${project.build.directory}/${project.build.finalName}/${gwt.module}
</classesDirectory>
</configuration>
</plugin>
</plugins>
</build>

</project>

这里是测试用例,位于/src/test/java/com/myproject/test/ui

public class GwtTestMyFirstTestCase extends GWTTestCase {

@Override
public String getModuleName() {
return "com.myproject.MainModule";
}

public void testSomething() {


}

}

这是我要测试的 gwt 模块,位于 src/main/java/com/myproject/MainModule.gwt.xml 中:

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

<inherits name='com.myproject.Commons' />

<source path="site" />

<source path="com.myproject.test.ui" />

<set-property name="gwt.suppressNonStaticFinalFieldWarnings" value="true" />

<entry-point class='com.myproject.site.SiteModuleEntry' />
</module>

任何人都可以就我做错了什么给我一两个提示吗?

最佳答案

maven-gwt-plugin doc 重现 KevinWong 使用的解决方案,在尝试其他解决方案失败一个多小时后,它对我有用。

<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.6</version>
<configuration>
<additionalClasspathElements>
<additionalClasspathElement>${project.build.sourceDirectory}</additionalClasspathElement>
<additionalClasspathElement>${project.build.testSourceDirectory}</additionalClasspathElement>
</additionalClasspathElements>
<useManifestOnlyJar>false</useManifestOnlyJar>
<forkMode>always</forkMode>
<systemProperties>
<property>
<name>gwt.args</name>
<value>-out \${webAppDirectory}</value>
</property>
</systemProperties>
</configuration>
</plugin>

关于java - 使用 maven gwt 插件运行 GWTTestCase 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2737173/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com