我目前有一个命令行sbt -Dsome.configuration.option test
正在做我想要的,但我希望它自动为sbt test
应用该配置选项(而不是其他的sbt阶段)。如果我的术语正确,那么我想为测试配置设置 Java选项。我该怎么做?
搜索这些条款让我http://www.scala-sbt.org/release/docs/Testing.html,但我还没有理解它。
这个问题与我的问题类似:Define custom test configurations in sbt
答案 0 :(得分:6)
试试这个:
testOptions in Test +=
Tests.Setup(() => sys.props += "some.configuration.option" -> "true")
<强>警告:强>
因为你没有分叉,这会改变运行sbt本身的JVM中系统属性的状态。
这意味着在第一次运行测试后,如果您在sbt(run
/ runMain
)内运行main,那么系统属性也将被设置。