2

I have multiple IntelliJ (Scala) modules that have build.sbt file and scalatest code.

I also created ScalaTest configurations for each of them.

enter image description here

I can run the test one by one from the execution of sbt test. Is it possible to execute all the tests at once? I can think of making a Python/Bash script, but I wonder if there is a simple way to do it.

for d in dirs:
    execute("sbt test")

ADDED

From Alexey Romanov's answer, I created a build.sbt in the root directory with the following content

lazy val root = (project in file(".")).aggregate(context, contextProcessor)
lazy val context = project
lazy val contextProcessor = project

Then, I executed set test to make all the tests run.

[info] ContextTest:
[info] - Create context
[info] - Create context 2
[info] Run completed in 195 milliseconds.
[info] Total number of tests run: 2
[info] Suites: completed 1, aborted 0
[info] Tests: succeeded 2, failed 0, canceled 0, ignored 0, pending 0
[info] All tests passed.
[info] Compiling 1 Scala source to /Users/smcho/Desktop/code/ContextSharingSimulation/contextProcessor/target/scala-2.11/test-classes...
[info] DatabaseTest:
[info] - Create test
[info] - Create test2
[info] Run completed in 147 milliseconds.
[info] Total number of tests run: 2
[info] Suites: completed 1, aborted 0
[info] Tests: succeeded 2, failed 0, canceled 0, ignored 0, pending 0
[info] All tests passed.
[success] Total time: 5 s, completed Aug 12, 2015 3:03:41 PM

Reference - http://www.scala-sbt.org/0.13.5/docs/Getting-Started/Multi-Project.html

prosseek
  • 182,215
  • 215
  • 566
  • 871

1 Answers1

2
; <module1>/test; <module2>/test; <module3>/test

Or create an aggregate project:

// in build.sbt
lazy val root = (project in file(".")).
  aggregate(<module1>, ...)

Now you can just run sbt test. Actually, it should already be there by default:

If a project is not defined for the root directory in the build, sbt creates a default one that aggregates all other projects in the build.

Alexey Romanov
  • 167,066
  • 35
  • 309
  • 487