title: Error while running spring boot tests, SpringRunner.class Not found
body: <p>When I try to invoke JUnit test cases from my Spring Boot Application, I am getting following error:</p>
  
  <p>I am using this annotation in my Test class.</p>
  
  <blockquote>
    <p>@RunWith(SpringRunner.class)</p>
  </blockquote>
  
  <p><a href="https://i.stack.imgur.com/6ieeo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6ieeo.png" alt="enter image description here"></a></p>
  
  <p>After I add JUnit library from project dependencies, it gives me following error:</p>
  
  <p><a href="https://i.stack.imgur.com/iOge0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iOge0.png" alt="enter image description here"></a></p>
  
  <pre><code>java.lang.TypeNotPresentException: Type org.springframework.test.context.junit4.SpringRunner not present
      at sun.reflect.annotation.TypeNotPresentExceptionProxy.generateException(TypeNotPresentExceptionProxy.java:46)
      at sun.reflect.annotation.AnnotationInvocationHandler.invoke(AnnotationInvocationHandler.java:84)
      at com.sun.proxy.$Proxy2.value(Unknown Source)
      at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:86)
      at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
      at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
      at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
      at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:33)
      at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createUnfilteredTest(JUnit4TestLoader.java:87)
      at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:73)
      at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:46)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:522)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:760)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:460)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:206)
  Caused by: java.lang.ClassNotFoundException: org.springframework.test.context.junit4.SpringRunner
      at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
      at java.lang.Class.forName0(Native Method)
      at java.lang.Class.forName(Class.java:348)
      at sun.reflect.generics.factory.CoreReflectionFactory.makeNamedType(CoreReflectionFactory.java:114)
      at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:125)
      at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49)
      at sun.reflect.annotation.AnnotationParser.parseSig(AnnotationParser.java:439)
      at sun.reflect.annotation.AnnotationParser.parseClassValue(AnnotationParser.java:420)
      at sun.reflect.annotation.AnnotationParser.parseMemberValue(AnnotationParser.java:349)
      at sun.reflect.annotation.AnnotationParser.parseAnnotation2(AnnotationParser.java:286)
      at sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:120)
      at sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:72)
      at java.lang.Class.createAnnotationData(Class.java:3521)
      at java.lang.Class.annotationData(Class.java:3510)
      at java.lang.Class.getAnnotation(Class.java:3415)
      at org.junit.internal.builders.IgnoredBuilder.runnerForClass(IgnoredBuilder.java:10)
      ... 11 more
  </code></pre>
  
  <p>Here is my gradle dependencies:
  <a href="https://i.stack.imgur.com/rIQyy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rIQyy.png" alt="enter image description here"></a></p>
  
  <p>Also, I have the affected class in the class path:
  <a href="https://i.stack.imgur.com/FculP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FculP.png" alt="enter image description here"></a></p>
  
  <p>My spring boot version is 2.0.4. Editor is SpringToolSuite. Could someone please help me resolve this?</p>
  
  <p>Thanks</p>