对于sbt中的testOnly
,我想使用特定的testOptions
(因此任务test
具有不同的testOptions
),并且我还要设置环境变量.. < / p>
任何例子?
答案 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