Reputation: 8146
I'm running sbt-assembly in order to build a single jar file that can be deployed elsewhere. I would like to run my tests against this jar file rather than against the local .class files. Running against the local .class files is the default with sbt test
but I want to test the jar instead (but without incorporating the test class files into the jar).
Upvotes: 4
Views: 2903
Reputation: 9734
To build assembly jar in test you need to configuration
import AssemblyKeys._
Project.inConfig(Test)(baseAssemblySettings)
jarName in (Test, assembly) := s"${name.value}-test-${version.value}.jar"
So now you can prepare uber-jar with test:assembly. However I don't know easy way to run tests from sbt with this jar. I would go for custom command, something like test:run-test-assembly that will do something like this internally
scala -classpath uber-jar-test.jar classpath scalatest-<version>.jar org.scalatest.tools.Runner -p compiled_tests
sbt-assembly is running tests during assembly phase, but I'm pretty sure it's doing it agains not yet packaged classes. Sou you probably want to exclude them from assembly phase with
test in (Test, assembly) := {}
Upvotes: 1