简体   繁体   English

单gradle工作者进行单元测试

[英]Single gradle worker for unit tests

Is it possible to let gradle know to use a single worker thread for all my unit tests? 是否可以让gradle知道对我的所有单元测试都使用单个工作线程? In console I could see many gradle workers are invoked in parallel to execute unit tests. 在控制台中,我可以看到许多gradle worker被并行调用以执行单元测试。 In my case, that is not desired and I want Gradle to invoke the unit tests in a particular sequence. 就我而言,这是不希望的,我希望Gradle按特定顺序调用单元测试。 I have already created multiple test tasks and added dependsOn attribute so there is one level of sequencing already applied. 我已经创建了多个测试任务,并添加了dependsOn属性,因此已经应用了一层排序。 However, for some test tasks, there are multiple unit tests and those are not sequenced. 但是,对于某些测试任务,存在多个单元测试,而这些测试未排序。 Gradle engages multiple workers here. Gradle在这里雇用了多名工人。 Is there a way to make this also sequential? 有没有办法使这也顺序?

By default, a Test task will fork a single test JVM, which will run all of the task's tests sequentially. 默认情况下,一个Test任务将派生一个测试JVM,它将依次运行该任务的所有测试。 Test execution order can be controlled on the test framework level (eg by using JUnit suites), or by using multiple Test tasks rather than a single one. 测试执行顺序可以在测试框架级别上进行控制(例如,通过使用JUnit套件),或者通过使用多个Test任务而不是单个任务来控制。

When setting Test#maxParallelForks to a value higher than 1, a Test task will launch multiple test JVMs, and will spread test (class) execution across them. Test#maxParallelForks设置为大于1的值时, Test任务将启动多个测试JVM,并将测试(类)执行分散到它们之间。 As before, each test JVM will run its tests in a single thread. 和以前一样,每个测试JVM将在单个线程中运行其测试。

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

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