Skip to content

Commit f71f8a5

Browse files
committed
review comments
Issue: #4321
1 parent 0e4b8e5 commit f71f8a5

File tree

1 file changed

+39
-12
lines changed

1 file changed

+39
-12
lines changed

documentation/src/docs/asciidoc/user-guide/migration-from-junit4.adoc

Lines changed: 39 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ concurrent test execution. It can be enabled and configured using the following
4545
<<running-tests-config-params, configuration parameters>>:
4646

4747
`junit.vintage.execution.parallel.enabled=true|false`::
48-
Enable/disable parallel execution (defaults to `false`).
49-
Requires opt-in for `classes` or `methods` to be executed in parallel using the configuration parameters below.
48+
Enable/disable parallel execution (defaults to `false`). Requires opt-in for `classes`
49+
or `methods` to be executed in parallel using the configuration parameters below.
5050

5151
`junit.vintage.execution.parallel.classes=true|false`::
5252
Enable/disable parallel execution of test classes (defaults to `false`).
@@ -55,17 +55,20 @@ Requires opt-in for `classes` or `methods` to be executed in parallel using the
5555
Enable/disable parallel execution of test methods (defaults to `false`).
5656

5757
`junit.vintage.execution.parallel.pool-size=<number>`::
58-
Specifies the size of the thread pool to be used for parallel execution.
59-
By default, the number of available processors is used.
58+
Specifies the size of the thread pool to be used for parallel execution. By default, the
59+
number of available processors is used.
6060

61+
[[migrating-from-junit4-parallel-execution-class-level]]
62+
==== Parallelization at Class Level
6163

62-
Let's assume we have two test classes `FooTest` and `BarTest` with each class containing three unit tests.
63-
Now, let's enable the parallel execution of test classes:
64+
Let's assume we have two test classes `FooTest` and `BarTest` with each class containing
65+
three unit tests. Now, let's enable the parallel execution of test classes:
6466

6567
[source,properties]
6668
----
6769
junit.vintage.execution.parallel.enabled=true
6870
junit.vintage.execution.parallel.classes=true
71+
junit.vintage.execution.parallel.pool-size=2
6972
----
7073

7174
With this setup, the `VintageTestEngine` will use two different threads,
@@ -81,17 +84,21 @@ ForkJoinPool-1-worker-1 - BarTest::test3
8184
ForkJoinPool-1-worker-2 - FooTest::test3
8285
----
8386

84-
On the other hand, we can enable the parallel test execution at a `method` level,
87+
[[migrating-from-junit4-parallel-execution-method-level]]
88+
==== Parallelization at Method Level
89+
90+
Alternatively, we can enable the parallel test execution at a `method` level,
8591
rather than the `class` level:
8692

8793
[source,properties]
8894
----
8995
junit.vintage.execution.parallel.enabled=true
9096
junit.vintage.execution.parallel.methods=true
97+
junit.vintage.execution.parallel.pool-size=4
9198
----
9299

93-
Therefore, the test methods from within a class will be executed in parallel,
94-
while different test classes will be executed sequentially:
100+
Therefore, the test methods from within a class will be executed in parallel, while
101+
different test classes will be executed sequentially:
95102

96103
[source,plaintext]
97104
----
@@ -104,17 +111,21 @@ ForkJoinPool-1-worker-2 - FooTest::test2
104111
ForkJoinPool-1-worker-1 - FooTest::test3
105112
----
106113

114+
[[migrating-from-junit4-parallel-execution-class-and-method-level]]
115+
==== Full Parallelization
116+
107117
Finally, we can also enable the parallelization at both `class` and `method` level:
108118

109119
[source,properties]
110120
----
111121
junit.vintage.execution.parallel.enabled=true
112122
junit.vintage.execution.parallel.classes=true
113123
junit.vintage.execution.parallel.methods=true
124+
junit.vintage.execution.parallel.pool-size=8
114125
----
115126

116-
With these properties set, the `VintageTestEngine` will execute all the tests classes
117-
and methods in parallel, potentially significantly reducing the overall test suite execution time:
127+
With these properties set, the `VintageTestEngine` will execute all the tests classes and
128+
methods in parallel, potentially significantly reducing the overall test suite execution time:
118129

119130
[source,plaintext]
120131
----
@@ -126,6 +137,22 @@ ForkJoinPool-1-worker-5 - BarTest::test2
126137
ForkJoinPool-1-worker-4 - BarTest::test1
127138
----
128139

140+
[[migrating-from-junit4-parallel-execution-disabled]]
141+
==== Sequential Execution
142+
143+
On the other hand, if we disable the parallel execution, the `VintageTestEngine`
144+
will execute the tests sequentially, regardless of the other properties:
145+
146+
[source,properties]
147+
----
148+
junit.vintage.execution.parallel.enabled=false
149+
junit.vintage.execution.parallel.classes=true
150+
junit.vintage.execution.parallel.methods=true
151+
----
152+
153+
Similarly, tests will be executed sequentially if you enable parallel execution in general
154+
but enable neither class-level nor method-level parallelization.
155+
129156
[[migrating-from-junit4-tips]]
130157
=== Migration Tips
131158

@@ -245,4 +272,4 @@ The methods affected by this change are the following:
245272
* `assertThrows`
246273
- Assumptions
247274
* `assumeTrue`
248-
* `assumeFalse`
275+
* `assumeFalse`

0 commit comments

Comments
 (0)