在 sbt 中执行多个 Scalatests [英] Execute multiple Scalatests in sbt

查看:20
本文介绍了在 sbt 中执行多个 Scalatests的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

我还为他们每个人都创建了 ScalaTest 配置.

I also created ScalaTest configurations for each of them.

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

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")

添加

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

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

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

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

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

推荐答案

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

或者创建一个聚合项目:

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

现在你可以运行sbt test.实际上,默认情况下它应该已经存在:

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

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

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.

这篇关于在 sbt 中执行多个 Scalatests的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆