I have followed the instructions on SBT's documentation for setting up test configurations. I have three test configurations Test, IntegrationTest, and AcceptanceTest. So my src directory looks like this:
My question is, how can I configure SBT to allow sharing of classes between these configurations? Example: I have a class in the "it" configuration for simplifying database setup and tear down. One of my acceptance tests in the "acceptance" configuration could make use of this class. How do I make that "it" class available to the test in "acceptance"
Many thanks in advance.
sbt maps each test class to a task. sbt runs tasks in parallel and within the same JVM by default.
ScalaTest is one of the main testing libraries for Scala projects, and in this lesson you'll see how to create a Scala project that uses ScalaTest. You'll also be able to compile, test, and run the project with sbt.
You can use Pretty Clean to clean the all of dev tools caches including SBT. PrettyClean also cleans the SBT project's target folder.
Run Scala tests with coverageOpen your project. Open the test in question in the editor. icon and select the Run 'name' with Coverage option.
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)
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)
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