【问题标题】:Execute multiple Scalatests in sbt在 sbt 中执行多个 Scalatests
【发布时间】:2015-11-25 09:38:41
【问题描述】:

我有多个具有 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

【问题讨论】:

    标签: scala sbt scalatest


    【解决方案1】:
    ; <module1>/test; <module2>/test; <module3>/test
    

    或者创建一个aggregate project

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

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

    如果没有为构建中的根目录定义项目,sbt 会创建一个默认项目,用于聚合构建中的所有其他项目。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-08-19
      • 2014-03-04
      • 1970-01-01
      • 1970-01-01
      • 2016-03-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多