我有一個打包成耳朵的項目。在過去一個月左右,系統測試已被禁用。我們重新開啓了它們,並一直在修復測試失敗和構建腳本的問題。我一直無法破解的最新問題:執行org.apache.maven.plugins時缺少必需的類:maven-surefire-plugin:2.14.1:test:org/junit/runner/notification/RunListener
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.14.1:test (default-test) on project systemTest: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.14.1:test failed: A required class was missing while executing org.apache.maven.plugins:maven-surefire-plugin:2.14.1:test: org/junit/runner/notification/RunListener
[ERROR] -----------------------------------------------------
[ERROR] realm = plugin>org.apache.maven.plugins:maven-surefire-plugin:2.14.1
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/home/tomcat/.m2/repository/org/apache/maven/plugins/maven-surefire-plugin/2.14.1/maven-surefire-plugin-2.14.1.jar
[ERROR] urls[1] = file:/home/tomcat/.m2/repository/org/apache/maven/surefire/surefire-junit47/2.14.1/surefire-junit47-2.14.1.jar
[ERROR] urls[2] = file:/home/tomcat/.m2/repository/org/apache/maven/surefire/common-junit48/2.14.1/common-junit48-2.14.1.jar
[ERROR] urls[3] = file:/home/tomcat/.m2/repository/org/apache/maven/surefire/common-junit4/2.14.1/common-junit4-2.14.1.jar
[ERROR] urls[4] = file:/home/tomcat/.m2/repository/org/apache/maven/surefire/common-junit3/2.14.1/common-junit3-2.14.1.jar
[ERROR] urls[5] = file:/home/tomcat/.m2/repository/org/apache/maven/surefire/surefire-grouper/2.14.1/surefire-grouper-2.14.1.jar
[ERROR] urls[6] = file:/home/tomcat/.m2/repository/org/apache/maven/shared/maven-shared-utils/0.4/maven-shared-utils-0.4.jar
[ERROR] urls[7] = file:/home/tomcat/.m2/repository/com/google/code/findbugs/jsr305/2.0.1/jsr305-2.0.1.jar
[ERROR] urls[8] = file:/home/tomcat/.m2/repository/org/apache/maven/surefire/common-java5/2.14.1/common-java5-2.14.1.jar
[ERROR] urls[9] = file:/home/tomcat/.m2/repository/org/apache/maven/surefire/maven-surefire-common/2.14.1/maven-surefire-common-2.14.1.jar
[ERROR] urls[10] = file:/home/tomcat/.m2/repository/org/apache/maven/surefire/surefire-booter/2.14.1/surefire-booter-2.14.1.jar
[ERROR] urls[11] = file:/home/tomcat/.m2/repository/org/codehaus/plexus/plexus-utils/1.5.1/plexus-utils-1.5.1.jar
[ERROR] urls[12] = file:/home/tomcat/.m2/repository/org/apache/maven/reporting/maven-reporting-api/2.0.9/maven-reporting-api-2.0.9.jar
[ERROR] urls[13] = file:/home/tomcat/.m2/repository/org/apache/commons/commons-lang3/3.1/commons-lang3-3.1.jar
[ERROR] urls[14] = file:/home/tomcat/.m2/repository/org/apache/maven/surefire/surefire-api/2.14.1/surefire-api-2.14.1.jar
[ERROR] urls[15] = file:/home/tomcat/.m2/repository/org/apache/maven/plugin-tools/maven-plugin-annotations/3.2/maven-plugin-annotations-3.2.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import from realm ClassRealm[maven.api, parent: null]]
[ERROR]
[ERROR] -----------------------------------------------------: org.junit.runner.notification.RunListener
[ERROR] -> [Help 1]
我無法弄清楚如何組織/ JUnit的/跑步/通知/ RunListener無法找到。整個項目是用maven構建的,junit
作爲測試依賴項包含在內。
據我們所知,除了構建服務器之外,完整的構建工作無處不在。第二個有趣的地方是,在構建服務器上,當系統測試不包含在內時,一切都可以正常工作,並且系統測試在單獨運行時工作正常。這個問題只發生在包括系統測試在內的完整項目時。
這是pom.xml
的該系統的相關部分測試
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<includes>
<include>com/crowncastle/test/*Test.class</include>
<include>com/crowncastle/test/suite/*TestSuite.class</include>
</includes>
<additionalClasspathElements>
<additionalClasspathElement>${basedir}${file.separator}..${file.separator}ear${file.separator}src${file.separator}main${file.separator}application${file.separator}APP-INF${file.separator}classes</additionalClasspathElement>
<additionalClasspathElement>${basedir}${file.separator}..${file.separator}ff${file.separator}src${file.separator}main${file.separator}resources</additionalClasspathElement>
<additionalClasspathElement>${basedir}${file.separator}..${file.separator}ff${file.separator}target${file.separator}classes</additionalClasspathElement>
<additionalClasspathElement>${basedir}${file.separator}..${file.separator}ff${file.separator}target${file.separator}test-classes</additionalClasspathElement>
</additionalClasspathElements>
<forkMode>always</forkMode>
<argLine>-Xmx1024m -XX:MaxPermSize=512m</argLine>
<runOrder>alphabetical</runOrder>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
<forkedProcessTimeoutInSeconds>900</forkedProcessTimeoutInSeconds>
</configuration>
</plugin>
更新 我想也許有一箇舊版本的junit
遊逛可能會造成問題,所以我跑mvn dependency:analyze
和mvn dependency:tree
,但唯一提及的junit
是junit 4.10
,這是合適的版本。
更新 我們能夠在我們的測試生成服務器上覆制問題。在此之前,我沒有提到開發人員工作站運行的是Windows 8,而構建服務器是Linux。所以它可能是一個Windows VS Linux的問題,但我不明白。
也許檢查你在構建服務器上沒有損壞的jar?也值得修復你的版本中的插件版本,以便它們在環境之間保持一致。 – 2013-05-07 14:49:05
你提出了一個好點,也許你可以幫助我。在googleing中,有人說他們擦掉了當地的maven回購站,併爲他們修復了類似的問題。我沒有擦拭它,因爲我不想影響其他版本。相反,我通過系統參數覆蓋回購地點,然後一切正常。由於事情在新的回購協議中起作用,我然後嘗試擦拭原始存儲庫並重新構建,但這次原來的錯誤又回來了。因此,使用新位置可以工作,但不會刪除原始位置。 – pgreen2 2013-05-07 15:17:04
嗯。不知道如果你刪除了當地的回購協議並重建它,那可能是什麼情況。我會檢查罐子是否匹配。如果還有其他版本,則可能會有不同的遠程存儲庫設置,因此您在本地存儲庫中獲得不同版本的jar版本,由於某些原因該版本不兼容。這不太可能,但可能。 – 2013-05-07 15:29:06