Here is the solution for this problem:
https://github.com/junit-team/junit5/issues/1773

It's because in the new version of JUnit 5, the dependencies were consolidated 
into a single one.
You can see it here:
https://junit.org/junit5/docs/snapshot/release-notes/index.html
"New junit-jupiter dependency-aggregating artifact for simplified dependency 
management in build tools"

-----Original Message-----
From: Karl Heinz Marbaise <khmarba...@gmx.de> 
Sent: Tuesday, February 12, 2019 4:59 PM
To: Maven Developers List <dev@maven.apache.org>; Ahmed Yarub 
<ahmed.ya...@m4u.com.br>
Subject: Re: java.lang.NoSuchMethodError: 
org.junit.platform.commons.util.ReflectionUtils.tryToLoadClass Migrating to 
5.4.0

Hi,

the issue is simply cause Spring Boot already has a dependency (import) to an 
older verison of JUnit Jupiter ....

the simple solution is to add the org.junit:junit-bom:5.4.0 before Spring Boot 
bom import...in your dependencyManagement

This will solve the issue.

Kind regards
Karl Heinz Marbaise

On 12.02.19 16:47, Ahmed Yarub wrote:
> JDK: 11
> Spring Boot: 2.1.2.RELEASE
> JUnit: 5.4.0
> Maven: 3.6.0
> Surefire: 3.0.0-M3
> 
> At first, I got the following error running the tests on IntelliJ and using 
> the command mvn clean install:
> 
> ```
> [INFO] --- maven-surefire-plugin:3.0.0-M3:test (default-test) @ xxxxx 
> --- [INFO] [INFO] 
> -------------------------------------------------------
> [INFO]  T E S T S
> [INFO] -------------------------------------------------------
> Feb 12, 2019 12:53:00 PM 
> org.junit.platform.launcher.core.DefaultLauncher handleThrowable
> WARNING: TestEngine with ID 'junit-jupiter' failed to execute tests
> java.lang.NoSuchMethodError: 
> org.junit.platform.commons.util.ReflectionUtils.tryToLoadClass(Ljava/lang/String;)Lorg/junit/platform/commons/function/Try;
>          at 
> org.junit.jupiter.engine.support.OpenTest4JAndJUnit4AwareThrowableColl
> ector.createAbortedExecutionPredicate(OpenTest4JAndJUnit4AwareThrowabl
> eCollecto
> ```
> After adding this dependency, I could run the tests in IntelliJ but not using 
> Maven:
> 
> ```
>          <dependency>
>              <groupId>org.junit.platform</groupId>
>              <artifactId>junit-platform-launcher</artifactId>
>              <version>1.4.0</version>
>              <scope>test</scope>
>          </dependency>
> ```
> Rolling back to version 5.3.2 solves the problem
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@maven.apache.org
For additional commands, e-mail: dev-h...@maven.apache.org

Reply via email to