如何将scalatest依赖项添加到现有的scala / lift项目?

时间:2015-03-15 11:51:00

标签: scala lift scalatest

我正在尝试为现有的scala和提升应用添加最常见的支持

我按照以下摘录

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

1 个答案:

答案 0 :(得分:3)

似乎您已指定scalatest的依赖关系仅对测试包可见,并且您的代码似乎并未位于那里。因此,要么将依赖项从build更改为build.sbt,要么将测试代码更好地移动到测试包中。