GWT:测试类“com.myco.clearing.commons.xml.XMLNodeTest”;在模块中找不到

发布于 2024-12-16 10:48:45 字数 3615 浏览 3 评论 0原文

我有一个 Maven (3.0.3) / GWT (2.4) 项目。我正在尝试编写一些 JUnit 测试用例,但遇到了问题。我的所有测试用例都扩展了 GWTTestCase 并包含此代码...

@Override
public String getModuleName() {
    return "com.myco.clearing.product.ProductPlus";
}

“ProductPlus.gwt.xml”文件位于我的 src/main/java 目录中。为了将其包含在我的类路径中,我为我的surefire-plugin配置了这个...

        <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>

但是,在运行“mvn clean test”时,我得到了所有这些错误,包括这个...

testParsingNodeWithAttributes(com.myco.clearing.commons.xml.XMLNodeTest)  Time elapsed: 2.563 sec  <<< ERROR!
com.google.gwt.junit.JUnitFatalLaunchException: The test class 'com.myco.clearing.commons.xml.XMLNodeTest' was not found in module 'com.myco.clearing.product.ProductPlus'; no compilation unit for that type was seen
at com.google.gwt.junit.JUnitShell.checkTestClassInCurrentModule(JUnitShell.java:743)
at com.google.gwt.junit.JUnitShell.runTestImpl(JUnitShell.java:1346)
at com.google.gwt.junit.JUnitShell.runTestImpl(JUnitShell.java:1309)
at com.google.gwt.junit.JUnitShell.runTest(JUnitShell.java:653)
at com.google.gwt.junit.client.GWTTestCase.runTest(GWTTestCase.java:441)
at junit.framework.TestCase.runBare(TestCase.java:134)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at com.google.gwt.junit.client.GWTTestCase.run(GWTTestCase.java:296)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at junit.framework.TestSuite.run(TestSuite.java:227)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:59)
at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:120)
at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:145)
at org.apache.maven.surefire.Surefire.run(Surefire.java:104)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:290)
at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1017)

这是一个奇怪的错误,因为有问题的类位于我的 src/test/java 目录中,我已将其包含为“additionalClassPathElement”(见上文)。我还需要进行哪些其他配置来纠正此错误? - 戴夫

I have a Maven (3.0.3) / GWT (2.4) project. I'm trying to write some JUnit test cases but running into issues. All my test cases extend GWTTestCase and include this code ...

@Override
public String getModuleName() {
    return "com.myco.clearing.product.ProductPlus";
}

The "ProductPlus.gwt.xml" file is located in my src/main/java directory. To include that in my classpath I have this configured for my surefire-plugin ...

        <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>

However, upon running "mvn clean test", I get all these errors, including this one ...

testParsingNodeWithAttributes(com.myco.clearing.commons.xml.XMLNodeTest)  Time elapsed: 2.563 sec  <<< ERROR!
com.google.gwt.junit.JUnitFatalLaunchException: The test class 'com.myco.clearing.commons.xml.XMLNodeTest' was not found in module 'com.myco.clearing.product.ProductPlus'; no compilation unit for that type was seen
at com.google.gwt.junit.JUnitShell.checkTestClassInCurrentModule(JUnitShell.java:743)
at com.google.gwt.junit.JUnitShell.runTestImpl(JUnitShell.java:1346)
at com.google.gwt.junit.JUnitShell.runTestImpl(JUnitShell.java:1309)
at com.google.gwt.junit.JUnitShell.runTest(JUnitShell.java:653)
at com.google.gwt.junit.client.GWTTestCase.runTest(GWTTestCase.java:441)
at junit.framework.TestCase.runBare(TestCase.java:134)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at com.google.gwt.junit.client.GWTTestCase.run(GWTTestCase.java:296)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at junit.framework.TestSuite.run(TestSuite.java:227)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:59)
at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:120)
at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:145)
at org.apache.maven.surefire.Surefire.run(Surefire.java:104)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:290)
at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1017)

This is a bizarre error because the class in question is in my src/test/java directory, which I have included as an "additionalClassPathElement" (above). What other configurations do I need to make to correct this error? - Dave

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

挖个坑埋了你 2024-12-23 10:48:45

用于测试的包必须位于指定模块的客户端类路径中。根据模块的名称,您的测试可能属于 com.myco.clearing.product.client 包或其子包。

The package for your test must be in the client classpath for the module specified. Based on the module's name, your test probably belongs in the com.myco.clearing.product.client package, or a subpackage of that.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文