Skip to content

Commit 0e4b8e5

Browse files
committed
improve junit vintage docs
Issue: #4321
1 parent 962b926 commit 0e4b8e5

File tree

1 file changed

+63
-8
lines changed

1 file changed

+63
-8
lines changed

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

Lines changed: 63 additions & 8 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`). Requires opt-in for `classes`
49-
or `methods` to be executed in parallel using the configuration parameters below.
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.
5050

5151
`junit.vintage.execution.parallel.classes=true|false`::
5252
Enable/disable parallel execution of test classes (defaults to `false`).
@@ -55,21 +55,76 @@ concurrent test execution. It can be enabled and configured using the following
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. By default, the
59-
number of available processors is used.
58+
Specifies the size of the thread pool to be used for parallel execution.
59+
By default, the number of available processors is used.
6060

61-
Example configuration in `junit-platform.properties`:
61+
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:
6264

6365
[source,properties]
6466
----
6567
junit.vintage.execution.parallel.enabled=true
6668
junit.vintage.execution.parallel.classes=true
69+
----
70+
71+
With this setup, the `VintageTestEngine` will use two different threads,
72+
one for each test class:
73+
74+
[source,plaintext]
75+
----
76+
ForkJoinPool-1-worker-1 - BarTest::test1
77+
ForkJoinPool-1-worker-2 - FooTest::test1
78+
ForkJoinPool-1-worker-1 - BarTest::test2
79+
ForkJoinPool-1-worker-2 - FooTest::test2
80+
ForkJoinPool-1-worker-1 - BarTest::test3
81+
ForkJoinPool-1-worker-2 - FooTest::test3
82+
----
83+
84+
On the other hand, we can enable the parallel test execution at a `method` level,
85+
rather than the `class` level:
86+
87+
[source,properties]
88+
----
89+
junit.vintage.execution.parallel.enabled=true
6790
junit.vintage.execution.parallel.methods=true
68-
junit.vintage.execution.parallel.pool-size=4
6991
----
7092

71-
With these properties set, the `VintageTestEngine` will execute tests in parallel,
72-
potentially significantly reducing the overall test suite execution time.
93+
Therefore, the test methods from within a class will be executed in parallel,
94+
while different test classes will be executed sequentially:
95+
96+
[source,plaintext]
97+
----
98+
ForkJoinPool-1-worker-1 - BarTest::test1
99+
ForkJoinPool-1-worker-2 - BarTest::test2
100+
ForkJoinPool-1-worker-3 - BarTest::test3
101+
102+
ForkJoinPool-1-worker-3 - FooTest::test1
103+
ForkJoinPool-1-worker-2 - FooTest::test2
104+
ForkJoinPool-1-worker-1 - FooTest::test3
105+
----
106+
107+
Finally, we can also enable the parallelization at both `class` and `method` level:
108+
109+
[source,properties]
110+
----
111+
junit.vintage.execution.parallel.enabled=true
112+
junit.vintage.execution.parallel.classes=true
113+
junit.vintage.execution.parallel.methods=true
114+
----
115+
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:
118+
119+
[source,plaintext]
120+
----
121+
ForkJoinPool-1-worker-6 - FooTest::test2
122+
ForkJoinPool-1-worker-7 - BarTest::test3
123+
ForkJoinPool-1-worker-3 - FooTest::test1
124+
ForkJoinPool-1-worker-8 - FooTest::test3
125+
ForkJoinPool-1-worker-5 - BarTest::test2
126+
ForkJoinPool-1-worker-4 - BarTest::test1
127+
----
73128

74129
[[migrating-from-junit4-tips]]
75130
=== Migration Tips

0 commit comments

Comments
 (0)