SBT - 覆盖testOnly

时间:2017-09-04 06:48:09

标签: sbt scalatest

对于sbt中的testOnly,我想使用特定的testOptions(因此任务test具有不同的testOptions),并且我还要设置环境变量.. < / p>

任何例子?

1 个答案:

答案 0 :(得分:0)

我通过引入新范围Diagnose修正了它:


lazy val Diagnose = config("diagnose") extend Test
lazy val diagnoseSettings = inConfig(Build.Diagnose)(Defaults.testTasks ++ Seq(testOptions += Tests.Argument(TestFrameworks.ScalaTest, "-oD"), envVars := Map("TEST_LOG_LEVEL" -> "debug")))

然后我在项目中使用它与这些设置相结合


val p = (project in file("project")).configs(Build.Diagnose).settings(Build.diagnoseSettings).settings(testOptions in Test += Tests.Argument(TestFrameworks.ScalaTest, "-W", "5", "2"), testOptions in Test += Tests.Argument(TestFrameworks.ScalaTest, "-oNCXEHLOPQRM"))

现在,当我运行sbt test时,它将仅显示失败的测试。如果您想查看失败原因,可以使用sbt diagnose:testOnly test-class