java.lang.NoClassDefFoundError: org/junit/platform/commons/PreconditionViolationException when trying run junit5 test with maven

后端 未结 8 1841
抹茶落季
抹茶落季 2020-12-10 00:56

When trying to run tests using command mvn test I receive an error:

[ERROR] There was an error in the forked process
[ERROR] java.lang.NoClassDefFou         


        
8条回答
  •  醉梦人生
    2020-12-10 01:25

    As others suggested, using JUnit 5.5.2 version is the way to go here. There are different alternatives to achieve this:

    1. If you're using spring-boot-starter-parent, you can upgrade it to 2.2.0.RELEASE
    2. If you use spring-boot-starter-parent (or spring-boot-dependencies), you can define a property to update just JUnit: 5.5.2
    3. If you're having this issue just in Eclipse, you can update it and add the JUnit 5 library to the Java Build Path (Project > Java Build Path > Libraries > Add Library > JUnit > JUnit 5 > Finish)
    4. You can add the Junit BOM, using 5.5.2 version (see Prasanth Rajendran or Ramit answer)

提交回复
热议问题