I am trying to add scalatest support to an existing scala and lift app
I add a dependency to build.sbt as per the following excerpt
resolvers ++= Seq(
"Java.net Maven2 Repository" at "http://download.java.net/maven/2/",
"Sonatype scala-tools repo" at "https://oss.sonatype.org/content/groups/scala-tools/",
"Sonatype scala-tools releases" at "https://oss.sonatype.org/content/repositories/releases",
"Sonatype scala-tools snapshots" at "https://oss.sonatype.org/content/repositories/snapshots"
)
libraryDependencies ++= {
val liftVersion = "2.6"
Seq(
"net.liftweb" %% "lift-webkit" % liftVersion % "compile",
"net.liftweb" %% "lift-mapper" % liftVersion % "compile",
"junit" % "junit" % "4.7" % "test",
"org.scalatest" % "scalatest_2.11" % "2.2.4" % "test"
)
}
and then I create a test class
class GeoUtilsTest extends org.scalatest.FlatSpec {
}
when I do sbt compile or sbt test I get the following error
[error] C:\Users\Andrew Bucknell\Documents\project-alpha\src\main\scala\com\myapp\api\utilities\GeoUtils$Test.scala:6: object scalatest is not a member of package org
[error] class GeoUtilsTest extends org.scalatest.FlatSpec {
[error] ^
The problem here is that scalatest cannot be found. I am not sure why adding the dependency to the build.sbt isnt enough to bring it in and add it to the project - its always been enough before. sbt update finds and downloads the dependency. Any thoughts?
It seems that you have specified the dependency of scalatest to be visible only to test package and you code doesn't seems to be located there. So, either change the dependency into build.sbt from test to compile, or better move the testing code into test package.