plaidshirt
plaidshirt

Reputation: 5671

initializationError when try to use @RunWith(SpringRunner.class)

I try to import in Intellij IDEA an existing project. All the dependencies are resolved and project build is successful. When I try to execute project I got following error message:

Could not initialize class org.springframework.test.context.junit4.SpringRunner

Following code didn't help me to solve this, I found it in another similar question.

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.10</version>
        <configuration>
            <junitArtifactName>junit:junit:4.12</junitArtifactName>
        </configuration>
    </plugin>

Version numbers:

Spring 4.3.3

Junit 4.12

Upvotes: 0

Views: 2064

Answers (1)

kris_k
kris_k

Reputation: 341

Without more details (e.g. sample project on github) it might be difficult for us to find a root cause.

It seems you are overriding junit version somewhere in your pom. As stated in documentation SpringRunner requires junit 4.12 or higher.

There was a similar bug reported for spring boot project: Spring Boot Issue 5695

You can use tools like mvn dependency:tree to find out actual project dependencies.

Upvotes: 2

Related Questions