TypeSafe-Activator ScalaTest值不是String的成员

时间:2015-08-12 15:59:29

标签: scalatest typesafe-activator

我正在尝试运行我克隆的项目的测试。我是Scala和Activator的新手,我无法弄清楚发生了什么

在根文件夹中我有build.sbt

name := "xxxxx"

version := "2.0-SNAPSHOT"

scalaVersion := "2.11.5"

doc in Compile <<= target.map(_ / "none")

scalacOptions ++= Seq("-unchecked", "-deprecation", "-feature")

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

libraryDependencies ++= Seq(
  jdbc,
  anorm,
  cache,
  "org.scalatest" % "scalatest_2.11" % "2.2.4" % "test",
  "json-module" %% "json-module" % "2.0.0",
  )

instrumentSettings

ScoverageKeys.excludedPackages in ScoverageCompile := "<empty>;views*;views.*;views*html;Routes*;controllers*routes*;controllers*Reverse*;controllers*javascript*;controller*ref*"

ScoverageKeys.highlighting := true

这是一个示例文件

class TestExampleSpec extends AbstractSpec {

  "TestExample#get(:testId)" must {
    val url = controllers.routes.TestExample.get(1, 1, 10).url

    "return 400 without X-Client-Id header" in {
      val fakeRequest = FakeRequest("GET", url).withTextBody("")

      val result: Future[Result] = controllers.TestExample.get(1, 1, 10)(fakeRequest)

      status(result) mustBe 400
      contentType(result) mustBe Some("application/json")
      val body = contentAsString(result)
      val bodyJson = Json.parse(body)

      (bodyJson \ "error").asOpt[Boolean] mustBe Some(true)
      (bodyJson \ "message").asOpt[String] mustBe Some("Missing X-Client-Id header")
    }

我尝试了这个命令

$ activator reload
$ activator clean
$ activator test

但这一切都没有用,我收到了这样的消息

home/username/code/testing-project/test/TestExampleSpec.scala:10: value in is not a member of String
  "return 400 without X-Client-Id header" in {

谢谢

1 个答案:

答案 0 :(得分:0)

我认为这个问题是相关的,因为该项目已从第2.2场改为2.3.8

我添加了这种依赖

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

这似乎成功了。

相关问题