在 sbt 中执行多个 Scalatest

Execute multiple Scalatests in sbt

我有多个具有 build.sbt 文件和 scalatest 代码的 IntelliJ (Scala) 模块。

我还为它们中的每一个创建了 ScalaTest 配置。

我可以 运行 从执行 sbt test 开始一项一项地进行测试。 是否可以一次执行所有测试?我可以考虑制作一个 Python/Bash 脚本,但我想知道是否有一种简单的方法可以做到这一点。

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

已添加

根据 Alexey Romanov 的回答,我在根目录中创建了一个 build.sbt,内容如下

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

然后,我执行了set test来完成所有的测试运行。

[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

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

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

或创建 aggregate project:

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

现在您可以 运行 sbt test。实际上,它应该已经默认存在了:

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.