I am trying to write a task that takes an input argument, pass it to the testOnly task and execute. It works fine, but I canβt establish the correctness of the system in this task, which will be visible in the test. These properties should not affect other tasks and should be visible only in this custom task.
Here is my sample code
lazy val myTestOnly = InputKey[Unit]("myTestOnly", "test only with special sys prop") val myTestOnlyTask = myTestOnly := { Def.inputTaskDyn { val args: Seq[String] = spaceDelimited("").parsed javaOptions in Test ++= Seq("-Dfoo=bar") // does not work testOptions += Tests.Setup(() => System.setProperty("foo", "bar")) //does not work System.setProperty("foo", "bar") // does not work (testOnly in Test).toTask(" " + args.head) }.evaluated }
When I start the sbt console
myTestOnly com.sampleTest
testOnly is running, but the "foo" property is not displayed
So qustion - how to set a property in the task definition that will be displayed in the test version only for the current task?
source share