如何将 scalatest 依赖项添加到现有 scala/lift 项目?
How do I add scalatest dependency to an existing scala/lift project?
我正在尝试为现有的 scala 和 lift 应用程序添加 scalatest 支持
我根据以下摘录向 build.sbt 添加依赖项
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"
)
}
然后我创建一个测试 class
class GeoUtilsTest extends org.scalatest.FlatSpec {
}
当我进行 sbt 编译或 sbt 测试时,出现以下错误
[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] ^
这里的问题是找不到scalatest。我不确定为什么将依赖项添加到 build.sbt 不足以将其引入并将其添加到项目中 - 以前一直就足够了。 sbt update 查找并下载依赖项。有什么想法吗?
您似乎已将 scalatest 的依赖项指定为仅对测试包可见,而您的代码似乎并不位于此处。因此,要么将测试到编译的依赖项更改为build.sbt,要么最好将测试代码移动到测试包中。
我正在尝试为现有的 scala 和 lift 应用程序添加 scalatest 支持
我根据以下摘录向 build.sbt 添加依赖项
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"
)
}
然后我创建一个测试 class
class GeoUtilsTest extends org.scalatest.FlatSpec {
}
当我进行 sbt 编译或 sbt 测试时,出现以下错误
[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] ^
这里的问题是找不到scalatest。我不确定为什么将依赖项添加到 build.sbt 不足以将其引入并将其添加到项目中 - 以前一直就足够了。 sbt update 查找并下载依赖项。有什么想法吗?
您似乎已将 scalatest 的依赖项指定为仅对测试包可见,而您的代码似乎并不位于此处。因此,要么将测试到编译的依赖项更改为build.sbt,要么最好将测试代码移动到测试包中。