我想在sbt中使用额外的命令行参数运行集成测试,这取决于inputKey:
lazy val environmentTest = inputKey[Unit](
"Run integration tests in a specific environment.")
lazy val environmentFile = Def.setting {
(_: State) => fileParser(sourceDirectory.value / "it" / "conf")
}
environmentTest := {
val envSettings = Seq(
javaOptions in IntegrationTest += s"-Dconfig.file=${environmentFile.parsed.absolutePath}",
(fork in IntegrationTest) := true
)
val projectState = state.value
val envState = Project.extract(projectState).append(envSettings, projectState)
Project.extract(envState).runAggregated((test in IntegrationTest), envState)
},
但是,当我运行environmentTest输入任务时,没有任何反应。它不运行集成测试。它:测试工作正常。
如何使用额外的java选项运行集成测试,这取决于inputKey?
答案 0 :(得分:0)
使用Project.runTask解决:
environmentTest := {
val envSettings = Seq(
javaOptions in IntegrationTest += s"-Dconfig.file=${environmentFile.parsed.absolutePath}",
(fork in IntegrationTest) := true
)
val envState = Project.extract(state.value).append(envSettings, state.value)
Project.runTask((test in IntegrationTest), envState)
},