Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to compile tests with SBT without running them

Is there a way to build tests with SBT without running them?

My own use case is to run static analysis on the test code by using a scalac plugin. Another possible use case is to run some or all of the test code using a separate runner than the one built into SBT.

Ideally there would be a solution to this problem that applies to any SBT project. For example, Maven has a test-compile command that can be used just to compile the tests without running them. It would be great if SBT had the same thing.

Less ideal, but still very helpful, would be solutions that involve modifying the project's build files.

like image 383
user1809090 Avatar asked Dec 12 '12 19:12

user1809090


People also ask

Does sbt test compile?

The following commands will make sbt watch for source changes in the Test and Compile (default) configurations respectively and re-run the compile command. Note that because Test / compile depends on Compile / compile , source changes in the main source directory will trigger recompilation of the test sources.

How do I compile sbt?

sbt shell has a command prompt (with tab completion and history!). To compile again, press up arrow and then enter. To run your program, type run . To leave sbt shell, type exit or use Ctrl+D (Unix) or Ctrl+Z (Windows).


2 Answers

Just use the test:compile command.

like image 175
Guillaume Massé Avatar answered Oct 25 '22 13:10

Guillaume Massé


test:compile works for compiling your unit tests.

To compile integration tests you can use it:compile.

Another hint to continuously compile on every file change: ~test:compile

like image 21
Brendan Maguire Avatar answered Oct 25 '22 12:10

Brendan Maguire