Search code examples
scaladependenciessbtmockitoscalatest

ScalaTest and Mockito - unresolved dependency


I am trying the add the mockito dependency in the SBT build file, But it gives below unresolved dependency exception.

I am not sure if its the issue with Scala and Mockito version.

    scalaVersion := "2.11.8"

    libraryDependencies ++= Seq("org.scalatest" % "scalatest_2.11" % "2.2.2" % "test",
  "org.mockito" % "mockito-all" % "1.9.5" % "test")

Exception :

trace] Stack trace suppressed: run 'last *:ssExtractDependencies' for the full output.
[trace] Stack trace suppressed: run 'last *:update' for the full output.
[error] (*:ssExtractDependencies) sbt.ResolveException: unresolved dependency: org.mockito#mockito-all;1.9.5: not found
[error] (*:update) sbt.ResolveException: unresolved dependency: org.mockito#mockito-all;1.9.5: not found
[error] Total time: 23 s, completed Oct 12, 2017 3:13:16 PM

I have tried with different mockito version 1.8.5 as well. But no luck.

Thanks in advance.


Solution

  • I strongly advise not to use mockito-all with sbt, but use mockito-core instead. SBT is smart build system and it will figure out all dependencies for mockito-core, details. Here how your dependencies might look:

    libraryDependencies ++= Seq (
      "org.scalatest" %% "scalatest" % "3.0.1" % "test",
      "org.mockito" % "mockito-core" % "2.8.47" % "test"
    )