Skip to content

Instantly share code, notes, and snippets.

@choedl
Last active December 23, 2015 12:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save choedl/6634961 to your computer and use it in GitHub Desktop.
Save choedl/6634961 to your computer and use it in GitHub Desktop.
Example build with setup and cleanup methods in sbt 0.13. Does not work correctly.
import sbt._
import Keys._
object TestBuild extends Build {
lazy val root = Project(id = "root", base = file(".")).aggregate(project1, project2)
lazy val project1 = Project("project1", file("project1"),
settings = defaultSettings ++ Seq(
libraryDependencies += "org.specs2" %% "specs2" % "2.1.1" % "test"
)
)
lazy val project2 = Project("project2", file("project2"),
settings = defaultSettings ++ Seq(
libraryDependencies += "org.specs2" %% "specs2" % "2.1.1" % "test"
)
)
lazy val defaultSettings = Defaults.defaultSettings ++ Seq(
parallelExecution in Test := false,
testOptions in Test += Tests.Setup( () => startupDb() ),
testOptions in Test += Tests.Cleanup( () => shutdownDb() )
)
def startupDb() = {
println("startup, thread name = " + Thread.currentThread().getName)
}
def shutdownDb() = {
println("shutdown, thread name = " + Thread.currentThread().getName)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment