【问题标题】:TypeSafe-Activator ScalaTest value in is not a member of StringTypeSafe-Activator ScalaTest 值不是字符串的成员
【发布时间】:2015-08-12 15:59:29
【问题描述】:

我正在尝试对我克隆的项目进行测试。我是 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 {

谢谢

【问题讨论】:

    标签: scalatest typesafe-activator


    【解决方案1】:

    我认为问题是相关的,因为项目从 play 2.2 更改为 play 2.3.8

    我添加了这个依赖

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

    这似乎成功了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-05-31
      • 1970-01-01
      • 1970-01-01
      • 2022-01-15
      • 1970-01-01
      • 2013-10-11
      • 1970-01-01
      相关资源
      最近更新 更多