Free tools Windows power users keep installed
One-click scans. No signup required.
Set forkEvery = 1 on the Gradle Test task. Gradle will start a fresh test JVM for every test class, adding process-startup overhead. This is a deliberately slower configuration, useful for demonstrating how test-process lifecycle affects a build—not a performance recommendation.
Set forkEvery to 1
Add the setting to the Gradle test task you want to slow down. Use the syntax matching your build script:
As an Amazon Associate I earn from qualifying purchases.
Kotlin DSL
tasks.withType<Test>().configureEach {
forkEvery = 1
}
Groovy DSL
tasks.withType(Test).configureEach {
forkEvery = 1
}
Scope the configuration to the intended test task or tasks. In a multi-project build, apply it to the relevant subprojects or configure it through the shared convention used by those projects.
What this setting changes
Gradle runs tests in a forked JVM separate from the build process. The forkEvery property limits how many test classes run in one forked process: its default value, 0, means there is no class-count limit, so Gradle reuses the process across classes. A value of 1 starts a new process for each test class. Values above 1 allow that many classes per process before Gradle restarts it. Gradle describes forkEvery = 1 as “very expensive” because restarting processes can significantly affect performance (Gradle Test API).
#1 Best Overall
The added time depends on the number and size of test classes and the machine and environment running the build. There is no universal slowdown percentage or fixed number of seconds for this change.
Keep JUnit 5 and process forking separate
JUnit Jupiter tests run through the JUnit Platform, which is configured separately from the process-lifecycle setting. For example, a test task can use useJUnitPlatform() to select the platform; forkEvery does not select a JUnit engine or change which tests are discovered. See Gradle’s Java testing guide for test framework configuration.
Do not confuse it with parallel test processes
forkEvery controls when Gradle replaces a test process. maxParallelForks controls how many test processes can run concurrently. Gradle’s default for maxParallelForks is 1; increasing it may reduce elapsed time on a multicore machine, but concurrent execution assumes tests are isolated. Tests that share files, databases, or services can conflict and fail intermittently (Gradle Java testing guide).
| Setting | What it controls | Typical effect |
|---|---|---|
forkEvery |
Number of test classes run in one forked process | A lower limit restarts the JVM more often and adds startup overhead. |
maxParallelForks |
Maximum number of concurrent test processes | A higher value may increase throughput, with more resource use and possible conflicts from shared test state. |
For real slow-test diagnosis
If your goal is to find and reduce delays instead, inspect test durations and build timelines with Gradle Build Scan. Gradle’s performance guide discusses identifying slow tests, parallel execution, process forking, and report generation. Gradle produces HTML and JUnit XML test reports by default; disabling reports may reduce overhead in a large suite when you do not need them. These are separate diagnostic or optimization choices, not part of the one-line slowdown.
Rank #3
The behavior described here is documented in Gradle’s current Test API; check the API documentation for the Gradle version used by your project if version-specific details matter.
Quick Recap
Best Value
Rank #4
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




