Warm tip: This article is reproduced from serverfault.com, please click

How to change concurrency for test execution in sbt

发布于 2020-11-27 15:37:50

I would like to control the number of threads that sbt uses when running in parallel. One reason is that a lot of my tests are calling rest api's which means they are waiting most of the time, so if I increase the threads above the number of cpu's, the tests should run faster.

I've seen a lot of configurations that claim to do this, i.e.

concurrentRestrictions in Test := Tags.limit(Tags.CPU,16) :: Nil

But nothing seems to make any difference. Using sbt 1.4.3

Questioner
kostas.kougios
Viewed
0
Ivan Stanislavciuc 2020-12-04 04:27:22

The correct setting is

concurrentRestrictions in ThisBuild := Tags.limit(Tags.Test, 16 ) :: Nil

The CPU tag only limits compile by default. Please refer to these docs for more details.

The tasks that are currently tagged by default are:

compile : Compile, CPU

test : Test

update : Update, Network

publish, publishLocal : Publish, Network