Given a project using a build.sbt
file, I would like to have a common TestUtils.scala
file which the integration and unit tests both rely upon.
I have my src folder at src/scala
and my integration testing folder at it/scala
. My unit testing folder is at test/scala
, and contains the common TestsUtils.scala
file.
Currently I am running my tests through ScalaTest in Intellij. When I run it this way Intellij is able to determine the dependency from the integration testing folder on the unit testing folder. I am attempting to switch over to using a test
, it:test
and unit:test
set of SBT tasks. When I do so the integration testing folder fails to compile since it can't find the common TestUtils.scala
file. If I copy the TestUtils.scala
file over to my integration testing folder then it does compile but I don't want to have the same code in 2 locations.
Here are the approaches I see to resolve this:
src
folder (introduces src
reliance on scalatest
which I would prefer to avoid)integration
folder to use the file from the test
folder (don't know how to do this)Ideally I would like to use the third approach but don't know how to actually implement it. How do you get one folder to use another folder as a dependency in SBT? Is there a better approach I'm unaware of?
Based off of the comment above by Mario Galic I slightly modified it to work for my build.sbt file. I used the following code:
dependencyClasspath in IntegrationTest := (dependencyClasspath in IntegrationTest).value
++ (exportedProducts in Test).value