1
找不到測試類'com.myco.clearing.commons.xml.XMLNodeTest'我有一個Maven(3.0.3)/ GWT(2.4)項目。我正在嘗試編寫一些JUnit測試用例,但遇到問題。我所有的測試用例擴展GWTTestCase和包括此代碼...GWT:在模塊
@Override
public String getModuleName() {
return "com.myco.clearing.product.ProductPlus";
}
的「ProductPlus.gwt.xml」文件位於我的src/main/java目錄。要包括在我的類路徑我有這個配置對於我的萬無一失,插件...
<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乾淨的測試」,我得到所有這些錯誤,包括這一個...
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」(上面)包含在其中。我需要做些什麼其他配置才能糾正此錯誤? - Dave
您能否解釋一下如何實現?謝謝。 – Cornelius
@Cornelius如何實現?該包與項目中的正常客戶端代碼相同,只是在測試源代碼中,而不是常規源代碼。 –