为什么Scala playframework不能导入库

时间:2015-03-03 16:01:03

标签: scala testing playframework

我试图使用this tutorial。但是我在尝试导入库时遇到了困难

import org.scalatestplus.play._

我在build.sbt

中添加了这个依赖项
  libraryDependencies += "org.scalatestplus" % "play_2.10" % "1.2.0"

它不会更新依赖列表。

如果我尝试激活更新我成功

$ activator update

[info] Loading project definition from /Users/masum/work/app/project
[info] Set current project to app (in build file:/Users/masum/work/app/)
[info] Updating {file:/Users/masum/work/app/}root...
[info] Resolving jline#jline;2.12 ...
[info] downloading http://repo1.maven.org/maven2/org/scalatestplus/play_2.11/1.2.0/play_2.11-1.2.0.jar ...
  [info]    [SUCCESSFUL ] org.scalatestplus#play_2.11;1.2.0!play_2.11.jar (1253ms)
  [info] Done updating.
  [success] Total time: 6 s, completed Mar 3, 2015 5:50:21 PM

即便如此,我也不能

   import org.scalatestplus.play._

这是我的build.sbt: -

  lazy val root = (project in file(".")).enablePlugins(PlayScala)

  scalaVersion := "2.11.5"

  libraryDependencies += "org.scalatestplus" % "play_2.11" % "1.2.0" % "test"

 libraryDependencies ++= Seq(
 jdbc,
 anorm,
 cache,
 ws,
 "com.typesafe.slick" % "slick_2.11" % "3.0.0-M1",
 "com.typesafe.play" % "play-slick_2.11" % "0.8.1",
 "org.slf4j" % "slf4j-nop" % "1.6.4",
 "org.postgresql" % "postgresql" % "9.4-1200-jdbc41",
 "org.scalatest" % "scalatest_2.11" % "2.2.4" % "test",
 "org.mockito" % "mockito-core" % "1.10.19" % "test",
 "com.h2database" % "h2" % "1.3.166",
 "org.xerial" % "sqlite-jdbc" % "3.6.20",
 "org.scala-lang" % "scala-actors" % "2.11.0"
 )

有什么问题?如何导入org.scalatestplus.play._

使用测试代码

更新更多信息
  class StackSpec extends PlaySpec {

    "A Stack" must {
      "pop values in last-in-first-out order" in {
        val stack = new Stack[Int]
        stack.push(1)
        stack.push(2)
        stack.pop() mustBe 2
        stack.pop() mustBe 1
      }
      "throw NoSuchElementException if an empty stack is popped" in {
        val emptyStack = new Stack[Int]
        a [NoSuchElementException] must be thrownBy {
          emptyStack.pop()
        }
      }
    }
  }

1 个答案:

答案 0 :(得分:0)

我发现scalatestplus-play存在问题。检查@

https://github.com/scalatest/scalatestplus-play/issues/15

我在使用时为我工作

  "org.scalatestplus" %% "play" % "1.2.0" % "test"

感谢所有试图支持我的人。