我有一个打包为耳朵的项目。在过去一个月左右的时间里,系统测试已被禁用。我们重新打开它们,并一直在修复失败的测试和构建脚本的问题。我一直无法破解最新的问题:
[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]
我无法弄清楚如何找不到 org/junit/runner/notification/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 与 linux 的问题,但我不明白是什么。