如何在 SBT 中仅针对测试配置设置 Java 选项?
How do I set Java options in SBT for the test configuration only?
我目前有一个命令行 sbt -Dsome.configuration.option test
做我想做的事,但我希望它自动为 sbt test
应用该配置选项(而不是其他 sbt 阶段)。如果我的术语是正确的,那么我想为测试配置设置一个Java选项。我该怎么做?
搜索这些术语使我找到了 http://www.scala-sbt.org/release/docs/Testing.html,但我还无法理解它。
这个问题和我的很相似:Define custom test configurations in sbt
试试这个:
testOptions in Test +=
Tests.Setup(() => sys.props += "some.configuration.option" -> "true")
警告:
因为你没有分叉,这会改变 JVM 运行ning sbt 本身的系统状态 属性。
这意味着在 运行ning 第一次测试之后,系统 属性 也将被设置,例如,如果你 运行 你的 main 来自 sbt (run
/runMain
).
我目前有一个命令行 sbt -Dsome.configuration.option test
做我想做的事,但我希望它自动为 sbt test
应用该配置选项(而不是其他 sbt 阶段)。如果我的术语是正确的,那么我想为测试配置设置一个Java选项。我该怎么做?
搜索这些术语使我找到了 http://www.scala-sbt.org/release/docs/Testing.html,但我还无法理解它。
这个问题和我的很相似:Define custom test configurations in sbt
试试这个:
testOptions in Test +=
Tests.Setup(() => sys.props += "some.configuration.option" -> "true")
警告:
因为你没有分叉,这会改变 JVM 运行ning sbt 本身的系统状态 属性。
这意味着在 运行ning 第一次测试之后,系统 属性 也将被设置,例如,如果你 运行 你的 main 来自 sbt (run
/runMain
).