How to turn off parallel execution of tests for multi-project builds?

后端 未结 5 2135
死守一世寂寞
死守一世寂寞 2020-12-08 10:03

I have a multi-project build with tests in sub-projects and in a parent project. The build is aggregated so that the parent project runs all tests in child projects.

相关标签:
5条回答
  • 2020-12-08 10:26

    I think you can apply a setting across projects using scope ThisBuild, like

    parallelExecution in ThisBuild := false
    

    I don't know if you can combine that with scope Test, but it might not be necessary.

    0 讨论(0)
  • 2020-12-08 10:26

    This worked for me in 1.1.0:

    Test / parallelExecution := false

    0 讨论(0)
  • 2020-12-08 10:39

    See my answer here How to run subprojects tests (including setup methods) sequentially when testing

    There is another way to prevent parallel execution. You can make the test tasks of the different projects depend on each other:

    test in Project2 := (test in Project2).dependsOn(test in Project1).value
    parallelExecution in Test in Project2 := false
    
    0 讨论(0)
  • 2020-12-08 10:41

    To restrict the number of concurrently executing tests in all projects, use:

    concurrentRestrictions in Global += Tags.limit(Tags.Test, 1)
    

    See sbt documentation

    See discussion

    0 讨论(0)
  • 2020-12-08 10:48

    Another possibility, based on https://stackoverflow.com/a/27068019/1922026, is to define a command alias in the root project:

    .settings(addCommandAlias("test", ";s1/test;s2/test;s3/test"): _*)
    

    where s1, s2 and s3 are the sub-projects. When you are in root project and run "test" the tests will be executed sequentially and in the order defined.

    0 讨论(0)
提交回复
热议问题