Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error: cannot access BlockJUnit4ClassRunner

Tags:

junit4

maven

While i run the mvn install I'm able to find this above error .

This is my POM.xml i have configured JUnit.

      <dependency>
          <groupId>junit</groupId>
          <artifactId>junit</artifactId>
          <version>4.4</version>
          <scope>test</scope>
      </dependency>

This is the service Test class

   @RunWith(SpringJUnit4ClassRunner.class)
   @ContextConfiguration
   public class ServiceTestCase {

   protected static final Logger LOG =  Logger.getLogger(ServiceTestCase.class);

   @Configuration
   static class AccountServiceTestContextConfiguration {
    ....
    ....
    ....
   }

While compiling the above error I am getting. this Test class I have created in src/test/java

can any one please suggest. How to resolve this ?

When I remove the I am getting error as @Test is not recognise.

like image 472
Sachi-17 Avatar asked Aug 21 '15 12:08

Sachi-17


1 Answers

Ok, the solution might be quite simple: Update to JUnit 4.5 (or higher).

The javadoc of the BlockJUnit4Runner (which is the Superclass of the SpringJUnit4ClassRunner you are using) states:

@since 4.5

...but as you only use <version>4.4</version>, that's probably the whole problem. Just checked it and the class does simply not exist in JUnit 4.4, so you'll have to upgrade your JUnit version to fix that problem.

like image 112
Florian Schaetz Avatar answered Sep 24 '22 00:09

Florian Schaetz