简体   繁体   English

如何在 sbt 中更改测试执行的并发性

[英]How to change concurrency for test execution in sbt

I would like to control the number of threads that sbt uses when running in parallel.我想控制 sbt 在并行运行时使用的线程数。 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.一个原因是我的很多测试都在调用 rest api,这意味着它们大部分时间都在等待,所以如果我将线程数增加到 CPU 的数量以上,测试应该运行得更快。

I've seen a lot of configurations that claim to do this, ie我见过很多声称可以做到这一点的配置,即

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

But nothing seems to make any difference.但似乎没有任何区别。 Using sbt 1.4.3使用 sbt 1.4.3

The correct setting is正确的设置是

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

The CPU tag only limits compile by default. CPU标签默认只限制compile Please refer to these docs for more details.请参阅这些文档以获取更多详细信息。

The tasks that are currently tagged by default are:当前默认标记的任务是:

compile: Compile, CPU编译:编译,CPU

test: Test测试一下

update: Update, Network更新:更新,网络

publish, publishLocal: Publish, Network发布,发布本地:发布,网络

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM