Execute multiple Scalatests in sbt

谁说我不能喝 提交于 2019-12-11 03:52:26

问题


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

I also created ScalaTest configurations for each of them.

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

ADDED

From Alexey Romanov's answer, I created a build.sbt in the root directory with the following content

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

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

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


回答1:


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

Or create an aggregate project:

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

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

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.



来源:https://stackoverflow.com/questions/31972266/execute-multiple-scalatests-in-sbt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!