How do you share classes between test configurations using SBT

In case you want to stick with predefined configurations instead of defining new ones, and since both Test and IntegrationTest extend Runtime (one would expect IntegrationTest to extend Test…), you could use the following:

dependencyClasspath in IntegrationTest := (dependencyClasspath in IntegrationTest).value ++ (exportedProducts in Test).value

This should put all the classes you define in Test on the IntegrationTest classpth.

##EDIT:

I was just became aware to amuch better solution thanks to @mjhoy:

lazy val DeepIntegrationTest = IntegrationTest.extend(Test)

An approach is documented here: http://www.scala-sbt.org/release/docs/Detailed-Topics/Testing#additional-test-configurations-with-shared-sources


A configuration can extend another configuration to use that configuration's dependencies and classes. For example, the custom test configuration section shows this definition for the custom configuration:

lazy val FunTest = config("fun") extend(Test)

The extend part means that the compiled normal test sources will be on the classpath for fun sources. In your case, declare the acceptance configuration to extend the it configuration:

lazy val AcceptanceTest = config("acceptance") extend(IntegrationTest)

Tags:

Scala

Sbt