【问题标题】:How do I add scalatest dependency to an existing scala/lift project?如何将 scalatest 依赖项添加到现有的 scala/lift 项目?
【发布时间】:2015-03-15 20:01:45
【问题描述】:

我正在尝试向现有的 scala 和提升应用程序添加 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 GeoUtilsTest extends org.scalatest.FlatSpec {

}

当我执行 sbt compile 或 sbt test 时,出现以下错误

[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 查找并下载依赖项。有什么想法吗?

【问题讨论】:

    标签: scala lift scalatest


    【解决方案1】:

    您似乎已将 scalatest 的依赖项指定为仅对测试包可见,并且您的代码似乎不在此处。所以,要么把依赖从 test 改成 build.sbt 来编译,要么更好的把测试代码移到 test 包中。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-05-28
      • 1970-01-01
      • 1970-01-01
      • 2012-11-27
      • 1970-01-01
      • 2020-07-07
      • 2015-10-27
      • 1970-01-01
      相关资源
      最近更新 更多