Arranging IntegrationTests and Tests in multi module build

351 views
Skip to first unread message

Channing

unread,
Jun 13, 2013, 6:08:27 PM6/13/13
to simple-b...@googlegroups.com
Hi,
after a few days of reading docs and searching I have been unable to figure out the following.

I have a project with several sub projects. One of those subprojects contains integration tests, the others have tests.

Both the integration tests and the unit tests depend on test libs like specs2. Here is an example borrowed from the internet somewhere.

object BuildSettings {
  lazy val scalatest = "org.scalatest" %% "scalatest" % "1.9.1" // % "it, test"

  val buildSettings = Defaults.defaultSettings ++ Seq(

    organization := "com.softwaremill",
    version := "0.0.1-SNAPSHOT",
    scalaVersion := "2.10.2",
    libraryDependencies += scalatest
  )
}

object SomeBuild extends Build {
  import BuildSettings._

  lazy val parent: Project = Project(
    "root",
    file("."),
    settings = buildSettings
  ) aggregate(sub1, sub2)

  lazy val sub1: Project = Project(
    "sub1",
    file("sub1"),
    settings = buildSettings ++ Defaults.itSettings
  ).configs(IntegrationTest)

  lazy val sub2: Project = Project(
    "sub2",
    file("sub2"),
    settings = buildSettings
  )
}

This works, except that the libs each project depends on includes specs which isn't good when packaging everything up.

If I uncomment the '% "it, test"' in the declaration of scalatest, I get the following error

[error] (root/*:update) java.lang.IllegalArgumentException: Cannot add dependency 'org.scalatest#scalatest_2.10;1.9.1' to configuration 'it' of module com.softwaremill#root_2.10;0.0.1-SNAPSHOT because this configuration doesn't exist!

Whats the right way to do this?

Channing

Gerolf Seitz

unread,
Jun 14, 2013, 4:16:57 PM6/14/13
to simple-b...@googlegroups.com
Hi Channing,

I usually split up my settings in separate groups, similar to this:

import sbt._
import Keys._

object BuildSettings {
  lazy val scalatest = "org.scalatest" %% "scalatest" % "1.9.1"
  lazy val scalatest_test = scalatest % "test"
  lazy val scalatest_it = scalatest % "it"

  val buildSettings = Defaults.defaultSettings ++ Seq(
    organization := "com.softwaremill",
    version := "0.0.1-SNAPSHOT",
    scalaVersion := "2.10.2"
    // no library dependencies here. `parent` doesn't need any jar dependencies
  )

  // seperate default settings from test and it settings
  // use each collection of settings where appropriate
  val itSettings = Defaults.itSettings ++ Seq(
    libraryDependencies += scalatest_it
  )

  val testSettings = Seq(
    libraryDependencies += scalatest_test
  )
}

object SomeBuild extends Build {
  import BuildSettings._

  lazy val parent: Project = Project(
    "root",
    file("."),
    settings = buildSettings
  ) aggregate(sub1, sub2)

  lazy val sub1: Project = Project(
    "sub1",
    file("sub1"),
    settings = buildSettings ++ testSettings ++ itSettings
  ).configs(IntegrationTest)

  lazy val sub2: Project = Project(
    "sub2",
    file("sub2"),
    settings = buildSettings ++ testSettings
  )
}


HTH,
  Gerolf




Channing

--
You received this message because you are subscribed to the Google Groups "simple-build-tool" group.
To unsubscribe from this group and stop receiving emails from it, send an email to simple-build-t...@googlegroups.com.
To post to this group, send email to simple-b...@googlegroups.com.
Visit this group at http://groups.google.com/group/simple-build-tool.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Gerolf Seitz

twitter: @gersei

Channing Walton

unread,
Jun 14, 2013, 4:22:00 PM6/14/13
to simple-b...@googlegroups.com
Thanks Gerolf,

I hadn't thought of what you have done with scoping the libs like that. It seems a bit unfortunate to have to do that though but it solves the problem. 

Channing

You received this message because you are subscribed to a topic in the Google Groups "simple-build-tool" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/simple-build-tool/D2XnSWvIfyM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to simple-build-t...@googlegroups.com.

To post to this group, send email to simple-b...@googlegroups.com.
Visit this group at http://groups.google.com/group/simple-build-tool.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply all
Reply to author
Forward
0 new messages