ScalaTest:套件正在执行但实际上没有测试用例在运行?

标签 scala playframework scalatest

我正在使用最新版本的 Play 框架,以及来自 build.sbt 的以下测试依赖项文件:

"org.scalatest" %% "scalatest" % "3.0.0",
"org.scalatestplus.play" % "scalatestplus-play_2.11" % "2.0.0-M1"

我有一个基本规范,我的所有测试用例都从其扩展而来。我回了一个 Future[Assertion]在我的每一个条款中,它看起来像这样:
trait BaseSpec extends AsyncWordSpec with TestSuite with OneServerPerSuite with MustMatchers with ParallelTestExecution

示例规范如下所示:
"PUT /v1/user/create" should {
    "create a new user" in {
      wsClient
        .url(s"http://localhost:${port}/v1/user")
        .put(Json.obj(
          "name" -> "username",
          "email" -> "email",
          "password" -> "hunter12"
        )).map { response => response.status must equal(201) }
    }
}

我决定使用 AsyncWordSpec 重写我当前的测试由 ScalaTest 的较新版本提供,但是当我运行测试套件时,这是我得到的输出:
[info] UserControllerSpec:
[info] PUT /v1/user/create
[info] application - ApplicationTimer demo: Starting application at 2016-11-13T01:29:12.161Z.
[info] application - ApplicationTimer demo: Stopping application at 2016-11-13T01:29:12.416Z after 1s.
[info] application - ApplicationTimer demo: Stopping application at 2016-11-13T01:29:12.438Z after 0s.
[info] application - ApplicationTimer demo: Stopping application at 2016-11-13T01:29:12.716Z after 0s.
[info] application - ApplicationTimer demo: Stopping application at 2016-11-13T01:29:13.022Z after 1s.
[info] ScalaTest
[info] Run completed in 13 seconds, 540 milliseconds.
[info] Total number of tests run: 0
[info] Suites: completed 4, aborted 0
[info] Tests: succeeded 0, failed 0, canceled 0, ignored 0, pending 0
[info] No tests were executed.
[info] Passed: Total 0, Failed 0, Errors 0, Passed 0
[success] Total time: 20 s, completed Nov 12, 2016 8:29:13 PM

在调用 sbt test 时,我的所有测试类都由测试运行器找到、构建和运行。 .我也尝试过使用 IDEA 测试运行器,它报告 Empty Test Suite在我的每一节测试课下。我已经详尽地尝试了 RTFM,但我看不出我做错了什么。我的测试的同步版本运行完全正常。

编辑 1:一位 friend 建议尝试做 whenReady() { /* clause */ }在我的 Future[WSResponse] ,但这也失败了。

最佳答案

我在使用具有多个特征的测试套件时遇到了同样的问题。我通过删除除 AsyncFlatSpec 之外的所有其他特征来使其工作.我会在需要时一次添加一个。

关于ScalaTest:套件正在执行但实际上没有测试用例在运行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40569679/

相关文章:

scala - 如何形成 scala SortedMaps 的联合?

java - Play框架和Java版本

scala - 在 sbt 自定义测试任务中只运行标记测试

ScalaTest - 编写自定义匹配器

Scala Lift - 连接到远程 MongoDB

ScalaTest runner + FunSuite + 标签 : can't get `-n` and `-l` to include/exclude tag?

java.lang.Long 匹配 java.lang.String

java - Flash 作用域中的变量在 Google Chrome 中不存在

model-view-controller - 授权应该是模型或 Controller 的一部分吗?

斯卡拉 : How to create Unit test case in Intellij