I want to be able to switch between parallel and serial execution of scala tests using command line.
Working example with "test.par" system property:
val parallelTestOpt = Option(System.getProperty("test.par"))
testOptions in IntegrationTest += Tests.Argument(
//Configure distributor's pool size
parallelTestOpt.map(count =>s"-P$count").getOrElse("-P1")
)
lazy val root = (project in file("."))
.configs(IntegrationTest)
.settings(Defaults.itSettings,
//If suites are executed in parallel
IntegrationTest / parallelExecution := parallelTestOpt.exists(_ != "1"),
IntegrationTest / testForkedParallel := parallelTestOpt.exists(_ != "1")
)
The "problematic" part is the parallelTestOpt.map(count =>s"-P$count").getOrElse("-P1")
. I don't want to provide default value "-P1" when the "test.par" property was not specified. What is the best practice to achieve that ?
Maybe the whole concept is wrong and I should do it in a different way ?