How to make `sbt test` to run tests in main projec

2019-06-04 21:55发布

问题:

I have a main project and a few subprojects. When I want to run tests, currently I have to do sbt test and sbt subProjectName/test. Is there any way of making sbt run all tests or for example all tests in the main project and one of the subprojects.

I am using Build.scala configurations, but can't find a way of setting this.

Thanks!

回答1:

Therefore sbt supports aggregate.

for in depth details read: http://www.scala-sbt.org/0.13.5/docs/Getting-Started/Multi-Project.html#aggregation

In given example all commands at mainProject will also be run on other-project. So running mainProject/test will also run otherProject/test. If mainProject is your base project test will be enough.

in build.sbt

lazy val mainProject = 
   (project in file("."))
   .aggregate(otherProject)

lazy val otherProject = (project in file("other-project"))