I want to set another set of options for running tests in integration server and in dev environment.
Let's have this option:
testOptions := Seq(Tests.Filter(s => Seq("Spec", "Unit").exists(s.endsWith(_))))
How can change the testOptions
, so it is only applied, when the test
command is prefixed with some scope like teamcity:test
?
I expect, that the testOptions would be modified with similar syntax:
testOptions in Teamcity := ...
I also would like to know, how to define the custom scope, preferable in simple *.sbt
build, not in project/*.scala
build.
The scope could be either project, configuration, or task. In this case, I think you're looking to define a custom configuration.
There's a built-in configuration called IntegrationTest
already. You can define it in your build definition by writing:
Defaults.itSettings
This will use completely different setup from normal tests including the test code (goes into src/it/scala/
) and libraries, so this may not be what you want.
Using sbt 0.13, you can define a custom configuration as follows in build.sbt:
val TeamCity = config("teamcity") extend(Test)
val root = project.in(file(".")).
configs(TeamCity).
settings(/* your stuff here */, ...)
Now you have to figure out how to define teamcity:test
.
Edit: Mark Harrah pointed out to me that there's a documentation for this. See Additional test configurations with shared sources.
An alternative to adding separate sets of test sources (and compilations) is to share sources. In this approach, the sources are compiled together using the same classpath and are packaged together.
val TeamCity = config("teamcity") extend(Test)
val root = project.in(file(".")).
configs(TeamCity).
settings(
name := "helloworld",
libraryDependencies ++= Seq(
"org.specs2" %% "specs2" % "2.2" % "test"
)
).
settings(inConfig(TeamCity)(Defaults.testTasks ++ Seq(
testOptions := Seq(Tests.Argument("nocolor"))
)): _*)
When you run teamcity:test
the Specs2 output displays without color.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With