Skip to content

Latest commit

 

History

History
72 lines (42 loc) · 2.11 KB

Errors of Unit Test .md

File metadata and controls

72 lines (42 loc) · 2.11 KB

1, Run an individual test in Idea.

If you don't want to all the tests run in a class when you are trying to run a single test of a method. You should select "Skip Tests".

1712645962279

Or cancel "Delegate IDE... to Maven "

1712646233825

2, JUnit is not available

JUnit is not available in a project run by Idea.

Error:

org.junit.platform.commons.JUnitException: TestEngine with ID 'junit-jupiter' failed to discover tests

Solution:

The reason is as same as it in the 1. Just deselect "Delegate IDE build..."

3, Errors of Unit Test

1, An error occurs in a project of Idea. The exception is as follows.

command line is too long  also for junit

Solution:

In "Shorten command line" select JAR manifest.

1712796693495

4, NoClassDefFoundError

NoClassDefFoundError: org/springframework/core/CollectionFactory

  • The following test throws "NoClassDefFoundError: org/springframework/core/CollectionFactory".

  • The reason, which I guess, is the version of servlet-api(3.1.0) is different from

    the one which is 2.4 in "spring-mock" dependency.

  • Reason:

  • !!! How stupid I was. The exception stated clearly that there is no "CollectionFactory" which is

    a class of Spring Core. Just import the dependency!!

            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-core</artifactId>
                <!--Write a proper version correspond to spring-mock-->
                <version>${spring-core.version}</version>  
                <scope>compile</scope>
             </dependency>

5, incompatible version of Kotlin

Error: module was compiled with an incompatible version of kotlin

A solution:

Try going to Build menu and choose Rebuild project.