我正在使用IntelliJ
进行开发。我创建了一个test
文件夹,其中包含我的spec
文件。为了测试spec
s,我右键单击项目目录并选择run->all tests
。
我想创建一个sbt
任务来测试代码。我知道我必须在build.sbt
中定义tast但我不知道将运行测试的命令。
在运行中运行测试的命令是什么?文件说(https://www.playframework.com/documentation/2.7.x/ScalaTestingWithScalaTest#Testing-your-application-with-ScalaTest)
You can run tests from the Play console. To run all tests, run test.
。但我不知道怎么去玩游戏机。
我很乐意接受更好的答案。到目前为止,我已经完成了以下工作。基本上,要运行play
测试,我需要调用sbt test
。 play console
只是sbt console
的包装。在我的build.sbt
中,我写了以下任务。这些任务类似于在cmd
或terminal
中运行顶级项目目录并运行sbt test
。
在build.sbt中
def runBackendTests(implicit dir:File):Int = runScript("sbt test")
lazy val `backend-test` = taskKey[Unit]("Run Backend tests when testing application.")
`backend-test` := {
implicit val backendRoot = baseDirectory.value //this should be top level project directory. The tests are in test directory in this directory
println("backend root is ",backendRoot)
if(runBackendTests != 0) throw new Exception("Backend tests failed")
}