web-dev-qa-db-ja.com

jenkinsでmaven / surefireビルドを実行しているときに断続的なNoClassDefFoundError

多数の単体テストの実行を含め、Jenkinsで大規模なマルチモジュールMavenプロジェクトを構築しています。

数回のビルドごとに、ユニットjarにあるNoClassDefFoundError on RunListenerでビルドが失敗します。以下のログからわかるように、JUnitはクラスパスに含まれています。

エラーは完全にランダムに表示されるようです。

ログ

Waiting for Jenkins to finish collecting data
[ERROR] Failed to execute goal org.Apache.maven.plugins:maven-surefire-plugin:2.17:test (default-test) on project taboola-svc: Execution default-test of goal org.Apache.maven.plugins:maven-surefire-plugin:2.17:test failed: A required class was missing while executing org.Apache.maven.plugins:maven-surefire-plugin:2.17:test: org/junit/runner/notification/RunListener
[ERROR] -----------------------------------------------------
[ERROR] realm =    plugin>org.Apache.maven.plugins:maven-surefire-plugin:2.17
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/home/builder/.m2/repository/org/Apache/maven/plugins/maven-surefire-plugin/2.17/maven-surefire-plugin-2.17.jar
[ERROR] urls[1] = file:/home/builder/.m2/repository/org/Apache/maven/surefire/surefire-junit47/2.17/surefire-junit47-2.17.jar
[ERROR] urls[2] = file:/home/builder/.m2/repository/org/Apache/maven/surefire/common-junit48/2.17/common-junit48-2.17.jar
[ERROR] urls[3] = file:/home/builder/.m2/repository/org/Apache/maven/surefire/common-junit4/2.17/common-junit4-2.17.jar
[ERROR] urls[4] = file:/home/builder/.m2/repository/org/Apache/maven/surefire/common-junit3/2.17/common-junit3-2.17.jar
[ERROR] urls[5] = file:/home/builder/.m2/repository/org/Apache/maven/surefire/surefire-grouper/2.17/surefire-grouper-2.17.jar
[ERROR] urls[6] = file:/home/builder/.m2/repository/org/Apache/maven/shared/maven-shared-utils/0.4/maven-shared-utils-0.4.jar
[ERROR] urls[7] = file:/home/builder/.m2/repository/org/Apache/maven/surefire/common-Java5/2.17/common-Java5-2.17.jar
[ERROR] urls[8] = file:/home/builder/.m2/repository/junit/junit/4.11/junit-4.11.jar
[ERROR] urls[9] = file:/home/builder/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar
[ERROR] urls[10] = file:/home/builder/.m2/repository/org/Apache/maven/surefire/maven-surefire-common/2.17/maven-surefire-common-2.17.jar
[ERROR] urls[11] = file:/home/builder/.m2/repository/org/Apache/maven/surefire/surefire-booter/2.17/surefire-booter-2.17.jar
[ERROR] urls[12] = file:/home/builder/.m2/repository/org/codehaus/plexus/plexus-utils/1.5.1/plexus-utils-1.5.1.jar
[ERROR] urls[13] = file:/home/builder/.m2/repository/org/Apache/maven/reporting/maven-reporting-api/2.0.9/maven-reporting-api-2.0.9.jar
[ERROR] urls[14] = file:/home/builder/.m2/repository/org/Apache/commons/commons-lang3/3.1/commons-lang3-3.1.jar
[ERROR] urls[15] = file:/home/builder/.m2/repository/org/Apache/maven/surefire/surefire-api/2.17/surefire-api-2.17.jar
[ERROR] urls[16] = file:/home/builder/.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.Apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.Apache.maven.plugins:maven-surefire-plugin:2.17:test (default-test) on project taboola-svc: Execution default-test of goal org.Apache.maven.plugins:maven-surefire-plugin:2.17:test failed: A required class was missing while executing org.Apache.maven.plugins:maven-surefire-plugin:2.17:test: org/junit/runner/notification/RunListener
-----------------------------------------------------
realm =    plugin>org.Apache.maven.plugins:maven-surefire-plugin:2.17
strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
urls[0] = file:/home/builder/.m2/repository/org/Apache/maven/plugins/maven-surefire-plugin/2.17/maven-surefire-plugin-2.17.jar
urls[1] = file:/home/builder/.m2/repository/org/Apache/maven/surefire/surefire-junit47/2.17/surefire-junit47-2.17.jar
urls[2] = file:/home/builder/.m2/repository/org/Apache/maven/surefire/common-junit48/2.17/common-junit48-2.17.jar
urls[3] = file:/home/builder/.m2/repository/org/Apache/maven/surefire/common-junit4/2.17/common-junit4-2.17.jar
urls[4] = file:/home/builder/.m2/repository/org/Apache/maven/surefire/common-junit3/2.17/common-junit3-2.17.jar
urls[5] = file:/home/builder/.m2/repository/org/Apache/maven/surefire/surefire-grouper/2.17/surefire-grouper-2.17.jar
urls[6] = file:/home/builder/.m2/repository/org/Apache/maven/shared/maven-shared-utils/0.4/maven-shared-utils-0.4.jar
urls[7] = file:/home/builder/.m2/repository/org/Apache/maven/surefire/common-Java5/2.17/common-Java5-2.17.jar
urls[8] = file:/home/builder/.m2/repository/junit/junit/4.11/junit-4.11.jar
urls[9] = file:/home/builder/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar
urls[10] = file:/home/builder/.m2/repository/org/Apache/maven/surefire/maven-surefire-common/2.17/maven-surefire-common-2.17.jar
urls[11] = file:/home/builder/.m2/repository/org/Apache/maven/surefire/surefire-booter/2.17/surefire-booter-2.17.jar
urls[12] = file:/home/builder/.m2/repository/org/codehaus/plexus/plexus-utils/1.5.1/plexus-utils-1.5.1.jar
urls[13] = file:/home/builder/.m2/repository/org/Apache/maven/reporting/maven-reporting-api/2.0.9/maven-reporting-api-2.0.9.jar
urls[14] = file:/home/builder/.m2/repository/org/Apache/commons/commons-lang3/3.1/commons-lang3-3.1.jar
urls[15] = file:/home/builder/.m2/repository/org/Apache/maven/surefire/surefire-api/2.17/surefire-api-2.17.jar
urls[16] = file:/home/builder/.m2/repository/org/Apache/maven/plugin-tools/maven-plugin-annotations/3.2/maven-plugin-annotations-3.2.jar
Number of foreign imports: 1
import: Entry[import  from realm ClassRealm[maven.api, parent: null]]

-----------------------------------------------------

    at org.Apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.Java:225)
    at org.Apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.Java:153)
    at org.Apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.Java:145)
    at org.Apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.Java:84)
    at org.Apache.maven.lifecycle.internal.LifecycleThreadedBuilder$1.call(LifecycleThreadedBuilder.Java:167)
    at org.Apache.maven.lifecycle.internal.LifecycleThreadedBuilder$1.call(LifecycleThreadedBuilder.Java:163)
    at Java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.Java:303)
    at Java.util.concurrent.FutureTask.run(FutureTask.Java:138)
    at Java.util.concurrent.Executors$RunnableAdapter.call(Executors.Java:439)
    at Java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.Java:303)
    at Java.util.concurrent.FutureTask.run(FutureTask.Java:138)
    at Java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.Java:895)
    at Java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.Java:918)
    at Java.lang.Thread.run(Thread.Java:662)
Caused by: org.Apache.maven.plugin.PluginExecutionException: Execution default-test of goal org.Apache.maven.plugins:maven-surefire-plugin:2.17:test failed: A required class was missing while executing org.Apache.maven.plugins:maven-surefire-plugin:2.17:test: org/junit/runner/notification/RunListener
-----------------------------------------------------
realm =    plugin>org.Apache.maven.plugins:maven-surefire-plugin:2.17
strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
urls[0] = file:/home/builder/.m2/repository/org/Apache/maven/plugins/maven-surefire-plugin/2.17/maven-surefire-plugin-2.17.jar
urls[1] = file:/home/builder/.m2/repository/org/Apache/maven/surefire/surefire-junit47/2.17/surefire-junit47-2.17.jar
urls[2] = file:/home/builder/.m2/repository/org/Apache/maven/surefire/common-junit48/2.17/common-junit48-2.17.jar
urls[3] = file:/home/builder/.m2/repository/org/Apache/maven/surefire/common-junit4/2.17/common-junit4-2.17.jar
urls[4] = file:/home/builder/.m2/repository/org/Apache/maven/surefire/common-junit3/2.17/common-junit3-2.17.jar
urls[5] = file:/home/builder/.m2/repository/org/Apache/maven/surefire/surefire-grouper/2.17/surefire-grouper-2.17.jar
urls[6] = file:/home/builder/.m2/repository/org/Apache/maven/shared/maven-shared-utils/0.4/maven-shared-utils-0.4.jar
urls[7] = file:/home/builder/.m2/repository/org/Apache/maven/surefire/common-Java5/2.17/common-Java5-2.17.jar
urls[8] = file:/home/builder/.m2/repository/junit/junit/4.11/junit-4.11.jar
urls[9] = file:/home/builder/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar
urls[10] = file:/home/builder/.m2/repository/org/Apache/maven/surefire/maven-surefire-common/2.17/maven-surefire-common-2.17.jar
urls[11] = file:/home/builder/.m2/repository/org/Apache/maven/surefire/surefire-booter/2.17/surefire-booter-2.17.jar
urls[12] = file:/home/builder/.m2/repository/org/codehaus/plexus/plexus-utils/1.5.1/plexus-utils-1.5.1.jar
urls[13] = file:/home/builder/.m2/repository/org/Apache/maven/reporting/maven-reporting-api/2.0.9/maven-reporting-api-2.0.9.jar
urls[14] = file:/home/builder/.m2/repository/org/Apache/commons/commons-lang3/3.1/commons-lang3-3.1.jar
urls[15] = file:/home/builder/.m2/repository/org/Apache/maven/surefire/surefire-api/2.17/surefire-api-2.17.jar
urls[16] = file:/home/builder/.m2/repository/org/Apache/maven/plugin-tools/maven-plugin-annotations/3.2/maven-plugin-annotations-3.2.jar
Number of foreign imports: 1
import: Entry[import  from realm ClassRealm[maven.api, parent: null]]

-----------------------------------------------------

    at org.Apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.Java:127)
    at org.Apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.Java:209)
    ... 13 more
Caused by: org.Apache.maven.plugin.PluginContainerException: A required class was missing while executing org.Apache.maven.plugins:maven-surefire-plugin:2.17:test: org/junit/runner/notification/RunListener
-----------------------------------------------------
realm =    plugin>org.Apache.maven.plugins:maven-surefire-plugin:2.17
strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
urls[0] = file:/home/builder/.m2/repository/org/Apache/maven/plugins/maven-surefire-plugin/2.17/maven-surefire-plugin-2.17.jar
urls[1] = file:/home/builder/.m2/repository/org/Apache/maven/surefire/surefire-junit47/2.17/surefire-junit47-2.17.jar
urls[2] = file:/home/builder/.m2/repository/org/Apache/maven/surefire/common-junit48/2.17/common-junit48-2.17.jar
urls[3] = file:/home/builder/.m2/repository/org/Apache/maven/surefire/common-junit4/2.17/common-junit4-2.17.jar
urls[4] = file:/home/builder/.m2/repository/org/Apache/maven/surefire/common-junit3/2.17/common-junit3-2.17.jar
urls[5] = file:/home/builder/.m2/repository/org/Apache/maven/surefire/surefire-grouper/2.17/surefire-grouper-2.17.jar
urls[6] = file:/home/builder/.m2/repository/org/Apache/maven/shared/maven-shared-utils/0.4/maven-shared-utils-0.4.jar
urls[7] = file:/home/builder/.m2/repository/org/Apache/maven/surefire/common-Java5/2.17/common-Java5-2.17.jar
urls[8] = file:/home/builder/.m2/repository/junit/junit/4.11/junit-4.11.jar
urls[9] = file:/home/builder/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar
urls[10] = file:/home/builder/.m2/repository/org/Apache/maven/surefire/maven-surefire-common/2.17/maven-surefire-common-2.17.jar
urls[11] = file:/home/builder/.m2/repository/org/Apache/maven/surefire/surefire-booter/2.17/surefire-booter-2.17.jar
urls[12] = file:/home/builder/.m2/repository/org/codehaus/plexus/plexus-utils/1.5.1/plexus-utils-1.5.1.jar
urls[13] = file:/home/builder/.m2/repository/org/Apache/maven/reporting/maven-reporting-api/2.0.9/maven-reporting-api-2.0.9.jar
urls[14] = file:/home/builder/.m2/repository/org/Apache/commons/commons-lang3/3.1/commons-lang3-3.1.jar
urls[15] = file:/home/builder/.m2/repository/org/Apache/maven/surefire/surefire-api/2.17/surefire-api-2.17.jar
urls[16] = file:/home/builder/.m2/repository/org/Apache/maven/plugin-tools/maven-plugin-annotations/3.2/maven-plugin-annotations-3.2.jar
Number of foreign imports: 1
import: Entry[import  from realm ClassRealm[maven.api, parent: null]]

-----------------------------------------------------

    at org.Apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.Java:125)
    ... 14 more
Caused by: Java.lang.NoClassDefFoundError: org/junit/runner/notification/RunListener
    at Java.lang.ClassLoader.defineClass1(Native Method)
    at Java.lang.ClassLoader.defineClassCond(ClassLoader.Java:631)
    at Java.lang.ClassLoader.defineClass(ClassLoader.Java:615)
    at Java.security.SecureClassLoader.defineClass(SecureClassLoader.Java:141)
    at Java.net.URLClassLoader.defineClass(URLClassLoader.Java:283)
    at Java.net.URLClassLoader.access$000(URLClassLoader.Java:58)
    at Java.net.URLClassLoader$1.run(URLClassLoader.Java:197)
    at Java.security.AccessController.doPrivileged(Native Method)
    at Java.net.URLClassLoader.findClass(URLClassLoader.Java:190)
    at Java.lang.ClassLoader.loadClass(ClassLoader.Java:306)
    at Java.lang.ClassLoader.loadClass(ClassLoader.Java:247)
    at org.Apache.maven.surefire.booter.IsolatedClassLoader.loadClass(IsolatedClassLoader.Java:97)
    at Java.lang.ClassLoader.defineClass1(Native Method)
    at Java.lang.ClassLoader.defineClassCond(ClassLoader.Java:631)
    at Java.lang.ClassLoader.defineClass(ClassLoader.Java:615)
    at Java.security.SecureClassLoader.defineClass(SecureClassLoader.Java:141)
    at Java.net.URLClassLoader.defineClass(URLClassLoader.Java:283)
    at Java.net.URLClassLoader.access$000(URLClassLoader.Java:58)
    at Java.net.URLClassLoader$1.run(URLClassLoader.Java:197)
    at Java.security.AccessController.doPrivileged(Native Method)
    at Java.net.URLClassLoader.findClass(URLClassLoader.Java:190)
    at Java.lang.ClassLoader.loadClass(ClassLoader.Java:306)
    at Java.lang.ClassLoader.loadClass(ClassLoader.Java:247)
    at org.Apache.maven.surefire.booter.IsolatedClassLoader.loadClass(IsolatedClassLoader.Java:97)
    at Java.lang.Class.getDeclaredConstructors0(Native Method)
    at Java.lang.Class.privateGetDeclaredConstructors(Class.Java:2398)
    at Java.lang.Class.getConstructor0(Class.Java:2708)
    at Java.lang.Class.getConstructor(Class.Java:1659)
    at org.Apache.maven.surefire.util.ReflectionUtils.getConstructor(ReflectionUtils.Java:76)
    at org.Apache.maven.surefire.util.ReflectionUtils.instantiateOneArg(ReflectionUtils.Java:129)
    at org.Apache.maven.surefire.booter.SurefireReflector.instantiateProvider(SurefireReflector.Java:235)
    at org.Apache.maven.surefire.booter.ProviderFactory.createProvider(ProviderFactory.Java:113)
    at org.Apache.maven.plugin.surefire.booterclient.ForkStarter.getSuitesIterator(ForkStarter.Java:512)
    at org.Apache.maven.plugin.surefire.booterclient.ForkStarter.runSuitesForkPerTestSet(ForkStarter.Java:277)
    at org.Apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.Java:169)
    at org.Apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider(AbstractSurefireMojo.Java:967)
    at org.Apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.Java:831)
    at org.Apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.Java:729)
    at org.Apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.Java:101)
    ... 14 more
Caused by: Java.lang.ClassNotFoundException: org.junit.runner.notification.RunListener
    at Java.net.URLClassLoader$1.run(URLClassLoader.Java:202)
    at Java.security.AccessController.doPrivileged(Native Method)
    at Java.net.URLClassLoader.findClass(URLClassLoader.Java:190)
    at Java.lang.ClassLoader.loadClass(ClassLoader.Java:306)
    at Java.lang.ClassLoader.loadClass(ClassLoader.Java:247)
    at org.Apache.maven.surefire.booter.IsolatedClassLoader.loadClass(IsolatedClassLoader.Java:97)
    ... 53 more
[ERROR] 
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.Apache.org/confluence/display/MAVEN/PluginContainerException
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :taboola-svc

詳細

  • ビルドはスレーブで実行されています
  • ジェンキンスver。 1.565.2
  • Maven3.0.4と3.1.1の両方で試してみました
  • Surefire 2.16、17、18で試してみました
  • Junit 4.10&4.11で試してみました

MavenリポジトリでJUnitjarのSHA1を検証し、jarファイルが破損していないことを確認しました。


コマンドライン

(ジェンキンスの仕事で定義されています)

clean install -P FastTests -DIsBuildSystem=1 -T 4 -X -e

親pom.xmlからの関連部分

プロジェクト自体はマルチモジュールpomプロジェクトであり、親pomが確実な定義を添付として定義しています。

....

        <!-- Generic tests plugin for maven -->
        <plugin>
            <groupId>org.Apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>${testing.surefire.version}</version>
            <configuration>

                <systemPropertyVariables>
                    <startPortForDebug>${startPortForDebug}</startPortForDebug>
                    <surefireForkNumber>fork_${surefire.forkNumber}</surefireForkNumber>
                    <geoip.db.dir>${basedir}/../framework/target/</geoip.db.dir>
                    <Java.awt.headless>true</Java.awt.headless>
                    <redirectTestOutputToFile>true</redirectTestOutputToFile>
                </systemPropertyVariables>



                <!-- Use new JVM for each test -->
                <parallel>classes</parallel>

                <threadCount>1</threadCount>
                <forkCount>${testing.forkCount}</forkCount>
                <reuseForks>${testing.reuseFork}</reuseForks>
                <useSystemClassLoader>${testing.useSystemClassLoader}</useSystemClassLoader>
                <useManifestOnlyJar>${testing.useManifestOnlyJar}</useManifestOnlyJar>

                <!-- Display extra information on exception prints -->
                <useFile>true</useFile>
                <redirectTestOutputToFile>true</redirectTestOutputToFile>
                <runOrder>alphabetical</runOrder>

                <!-- Display extra information on exception prints -->
                <useFile>false</useFile>

                <!-- -->
                <forkedProcessTimeoutInSeconds>300</forkedProcessTimeoutInSeconds>


                <argLine>-XX:PermSize=128m -XX:MaxPermSize=512m -DIsBuildSystem=${is.build.system}</argLine>

            </configuration>
            <dependencies>
                <dependency>
                    <groupId>org.Apache.maven.surefire</groupId>
                    <artifactId>surefire-junit47</artifactId>
                    <version>${testing.surefire.version}</version>
                </dependency>
                <dependency>
                    <groupId>junit</groupId>
                    <artifactId>junit</artifactId>
                    <version>${junit.version}</version>
                </dependency>
            </dependencies>

        </plugin>

....
        <profile>
            <id>FastTests</id>
            <properties>
                <testing.forkCount>0.5C</testing.forkCount>
                <testing.reuseFork>false</testing.reuseFork>
                <testing.useSystemClassLoader>true</testing.useSystemClassLoader>
                <testing.useManifestOnlyJar>false</testing.useManifestOnlyJar>
            </properties>
        </profile>
15
Nitzan Volman

_-T 4_なしでMavenビルドを実行してみてください。

並列ビルド Maven 3の機能はまだ実験段階であり、バージョン2.0.5より前の_plexus-utils_ライブラリにはスレッドセーフに関する既知の問題があるようです-あなたはバージョン1.5.1を使用します。

編集:

あなたの問題はこの依存関係です:

_        <dependency>
            <groupId>org.Apache.maven.surefire</groupId>
            <artifactId>surefire-junit47</artifactId>
            <version>${testing.surefire.version}</version>
        </dependency>
_

_surefire-junit47__maven-surefire-common_ に依存し、これは _maven-artifact_ に依存し、_plexus-utils-1.5.1_。上で述べたように、これには既知のスレッドセーフの問題があり、これが問題の原因である可能性があります。 _surefire-junit47_ライブラリのどの部分を使用しているかはわかりませんが、_surefire-junit4_に切り替えることがオプションである場合は、それで問題が解決するはずです。

Surefireプラグインのドキュメントをもう少し見てみると、並列テストを実行するには_surefire-junit47_プロバイダーが必要なようです。 _plexus-utils_をバージョン2.0.5にオーバーライドして、それが機能するかどうかを確認します。それ以外の場合は、_maven-artifact_バージョンを3.0.3以降にオーバーライドして、それが機能するかどうかを確認できます。

10
Foxsly

surfire-junit4の代わりにsurfire-junit47を使用してみてください。

                <dependency>
                    <groupId>org.Apache.maven.surefire</groupId>
                    <artifactId>surefire-junit4</artifactId>
                    <version>${testing.surefire.version}</version>
                </dependency>

依存関係が少ないため、クラスパス/ランタイムの動作が変更されます。

enter image description here

並列サポートには必要ないため、この依存関係を完全に削除することもできます。

http://maven.Apache.org/surefire/maven-surefire-plugin/examples/junit.html

Surefire 2.7以降、オプションのフルセットを並列で使用するために追加の依存関係は必要ありません。Surefire 2.16以降、新しいスレッドカウント属性が導入されました。つまり、threadCountSuites、threadCountClasses、threadCountMethodsです。さらに、新しい属性parallelTestsTimeoutInSecondsおよびparallelTestsTimeoutForcedInSecondsは、タイムアウトが経過した後に並列実行をシャットダウンするために使用され、属性parallelは新しい値を指定します。

これで問題は解決しますか?

2
Donatello

ランダムなクラスローディングの問題があるようです。

JUnit 4以降、欠落しているクラスが表示されます: http://findjar.com/class/org/junit/runner/notification/RunListener.html

次の方法でsurfireクラスパスを分析してみてください。

  • 実行:mvn-Xクリーンテスト
  • ファイルを開く:target\surefire\surefire5942929663635698632tmp

次のようなものが表示されます:

surefireClassPathUrl.0=D\:\\maven2\\repository\\org\\Apache\\maven\\surefire\\surefire-junit47\\2.17\\surefire-junit47-2.17.jar
surefireClassPathUrl.1=D\:\\maven2\\repository\\org\\Apache\\maven\\surefire\\common-junit48\\2.17\\common-junit48-2.17.jar
surefireClassPathUrl.2=D\:\\maven2\\repository\\org\\Apache\\maven\\surefire\\common-junit4\\2.17\\common-junit4-2.17.jar
surefireClassPathUrl.3=D\:\\maven2\\repository\\org\\Apache\\maven\\surefire\\common-junit3\\2.17\\common-junit3-2.17.jar
surefireClassPathUrl.4=D\:\\maven2\\repository\\org\\Apache\\maven\\surefire\\surefire-api\\2.17\\surefire-api-2.17.jar
surefireClassPathUrl.5=D\:\\maven2\\repository\\org\\Apache\\maven\\surefire\\common-Java5\\2.17\\common-Java5-2.17.jar
surefireClassPathUrl.6=D\:\\maven2\\repository\\org\\Apache\\maven\\shared\\maven-shared-utils\\0.4\\maven-shared-utils-0.4.jar
surefireClassPathUrl.7=D\:\\maven2\\repository\\com\\google\\code\\findbugs\\jsr305\\2.0.1\\jsr305-2.0.1.jar
surefireClassPathUrl.8=D\:\\maven2\\repository\\org\\Apache\\maven\\surefire\\surefire-grouper\\2.17\\surefire-grouper-2.17.jar

JUnit3.x(および関連するjar)がロードされていないことを確認してください。

たとえば、common-junit3をsurfire-junit47から除外しようとする場合があります。

surfire-junit47 dependencies

                <dependency>
                    <groupId>org.Apache.maven.surefire</groupId>
                    <artifactId>surefire-junit47</artifactId>
                    <version>2.17</version>
                    <exclusions>
                        <exclusion>
                            <groupId>org.Apache.maven.surfire</groupId>
                            <artifactId>common-junit3</artifactId>
                        </exclusion>
                    </exclusions>
                </dependency>
1
Donatello

すべてのビルドが同じワークスペースを使用していて、複数のビルドが同時に実行されたり、何らかの方法でオーバーラップしたりする可能性がある場合、別のビルドがそれらを使用しようとしているときに、「クリーン」アクションが必要なビルドアーティファクトを消去している可能性があります。

それが起こっている場合、修正は、各ビルドの実行で独自のワークスペースを使用することです。

0
RichW