Anonymous
Anonymous

Reputation: 9648

How to run tests with target directory only (where test classes are compiled to)?

I use sbt 0.13.5.

I'd like to execute tests on a machine and given they're successful move the project to another machine and rerun them without compilation.

I tried sbt testOnly package_1 package_2 but it didn't work.

These are the steps of what I am trying to do:

  1. Compile the project using sbt clean compile. If I execute sbt testOnly myTest1 on this machine, it works fine.
  2. Create a zip file from everything in target
  3. Downloads the file on another machine
  4. Extracts it and run tests. (I only have target directory on this machine.)

Upvotes: 0

Views: 458

Answers (1)

Jacek Laskowski
Jacek Laskowski

Reputation: 74619

I think you won't be able to execute tests without some subset of build definition, i.e. you don't have all the dependencies of the project under tests. What's inside target is just the compiled sources you wrote in the project - there are no test libraries. sbt won't help you without helping sbt itself first.

You may mimic what sbt does with transitively downloading test and compile dependencies, but it's far too much work comparing to copying the build definition to the other machine.

What may work is to have build.sbt and target directory in a single (semi)project on the other machine. sbt test should work fine then (don't use clean for obvious reasons).

Upvotes: 0

Related Questions