Skip to content

Instantly share code, notes, and snippets.

@ninadingole
Last active March 17, 2019 13:21
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 ninadingole/b5bab2423a507d4b38376c51954b4aed to your computer and use it in GitHub Desktop.
Save ninadingole/b5bab2423a507d4b38376c51954b4aed to your computer and use it in GitHub Desktop.
Organising Scala Tests In SBT
#########################################
#### Inside project/E2E.class object ####
#########################################
import sbt.{Configuration, Defaults, Test, inConfig}
import sbt._
import sbt.Keys._
object E2E {
final val E2ETest = Configuration.of("EndToEndTest", "e2e") extend (Test)
final val e2eSettings =
inConfig(E2ETest)(e2eConfig)
lazy val e2eConfig = Defaults.configSettings ++ Defaults.testTasks ++ Seq(
scalaSource in E2ETest := baseDirectory.value / "src" / "e2e" / "scala",
javaSource in E2ETest := baseDirectory.value / "src" / "e2e" / "java",
resourceDirectory in E2ETest := baseDirectory.value / "src" / "e2e" / "resources",
E2ETest / parallelExecution := false
)
}
===================
###################
#### build.sbt ####
###################
import E2E._
lazy val scalatest = "org.scalatest" % "scalatest_2.11" % "3.0.5"
lazy val module1 = (project in file("module1"))
.configs(IntegrationTest)
.configs(E2ETest)
.settings(
E2E.e2eSettings,
Defaults.itSettings,
libraryDependencies += scalatest % "it,test,e2e",
name := "module1",
version := "0.1"
)
lazy val module2 = (project in file("module2"))
.configs(IntegrationTest)
.configs(E2ETest)
.settings(
Defaults.itSettings,
libraryDependencies += scalatest % "it,test,e2e",
E2E.e2eSettings,
name := "module2",
version := "0.1"
)
lazy val root = (project in file("."))
.configs(IntegrationTest)
.configs(E2ETest)
.aggregate(module1, module2)
.enablePlugins(Common)
.settings(
E2E.e2eSettings,
Defaults.itSettings,
libraryDependencies += scalatest % "it,test,e2e"
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment