Intermittent NoClassDefFoundError when running a maven/surefire build in jenkins

后端 未结 4 1783
天涯浪人
天涯浪人 2021-02-04 06:24

We are building a large multi module Maven project on Jenkins, including running a large number of unit test.

Once every few builds the build fails on NoClassDefF

4条回答
  •  抹茶落季
    2021-02-04 06:47

    Just try to use the surfire-junit4 in place of surfire-junit47 :

                    
                        org.apache.maven.surefire
                        surefire-junit4
                        ${testing.surefire.version}
                    
    

    It will change classpath/runtime behavior, as it comes with less dependencies :

    enter image description here

    You may also try to completely remove this dependency as it's not required for parallel support :

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

    As of Surefire 2.7, no additional dependencies are needed to use the full set of options with parallel. As of Surefire 2.16, new thread-count attributes are introduced, namely threadCountSuites, threadCountClasses and threadCountMethods. Additionally, the new attributes parallelTestsTimeoutInSeconds and parallelTestsTimeoutForcedInSeconds are used to shut down the parallel execution after an elapsed timeout, and the attribute parallel specifies new values.

    Does this solve the problem ?

提交回复
热议问题