I have a multi-project build with tests in sub-projects and in a parent project. The build is aggregated so that the parent project runs all tests in child projects.
I think you can apply a setting across projects using scope ThisBuild
, like
parallelExecution in ThisBuild := false
I don't know if you can combine that with scope Test
, but it might not be necessary.
This worked for me in 1.1.0:
Test / parallelExecution := false
See my answer here How to run subprojects tests (including setup methods) sequentially when testing
There is another way to prevent parallel execution. You can make the test tasks of the different projects depend on each other:
test in Project2 := (test in Project2).dependsOn(test in Project1).value
parallelExecution in Test in Project2 := false
To restrict the number of concurrently executing tests in all projects, use:
concurrentRestrictions in Global += Tags.limit(Tags.Test, 1)
See sbt documentation
See discussion
Another possibility, based on https://stackoverflow.com/a/27068019/1922026, is to define a command alias in the root project:
.settings(addCommandAlias("test", ";s1/test;s2/test;s3/test"): _*)
where s1, s2 and s3 are the sub-projects. When you are in root project and run "test" the tests will be executed sequentially and in the order defined.