Skip to content

Commit 71b8c0a

Browse files
authored
Merge branch 'main' into experiments/junit-onramp
2 parents fc5e954 + 786aa07 commit 71b8c0a

File tree

52 files changed

+2607
-222
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+2607
-222
lines changed

.idea/icon.png

8.01 KB
Loading

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
# <img src="https://junit.org/assets/img/junit6-temporary-logo.png" align="right" width="100">JUnit
1+
<h1>
2+
<picture width="200">
3+
<source media="(prefers-color-scheme: dark)" srcset="https://junit.org/assets/img/junit-logo-inverted-darker.svg">
4+
<source media="(prefers-color-scheme: light)" srcset="https://junit.org/assets/img/junit-logo.svg">
5+
<img alt="JUnit" src="https://junit.org/assets/img/junit-logo.svg" width="200">
6+
</picture>
7+
</h1>
28

39
This repository is the home of JUnit Platform, Jupiter, and Vintage.
410

documentation/documentation.gradle.kts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,12 @@ tasks {
363363
}
364364

365365
asciidoctorPdf {
366-
setExecutionMode(JAVA_EXEC) // Avoid classpath conflicts with other Gradle plugins (e.g. JReleaser)
366+
// Avoid classpath conflicts with other Gradle plugins (e.g. JReleaser)
367+
// Avoid propagating apparent memory leaks in Asciidoctor/JRuby to Gradle daemon.
368+
setExecutionMode(JAVA_EXEC)
369+
jvm {
370+
maxHeapSize = "512M"
371+
}
367372
sources {
368373
include("user-guide/index.adoc")
369374
}
@@ -474,7 +479,7 @@ tasks {
474479
}
475480
from(inputDir) {
476481
filesMatching("**/*.html") {
477-
val favicon = "<link rel=\"icon\" type=\"image/png\" href=\"https://junit.org/assets/img/junit6-temporary-logo.png\">"
482+
val favicon = "<link rel=\"icon\" type=\"image/png\" href=\"https://junit.org/assets/img/junit-diamond.png\">"
478483
filter { line ->
479484
var result = if (line.startsWith("<head>")) line.replace("<head>", "<head>$favicon") else line
480485
externalModulesWithoutModularJavadoc.forEach { (moduleName, baseUrl) ->

documentation/src/docs/asciidoc/docinfos/docinfo.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<link rel="icon" type="image/png" href="https://junit.org/assets/img/junit6-temporary-logo.png" />
1+
<link rel="icon" type="image/png" href="https://junit.org/assets/img/junit-diamond.png" />
22
<style>
33
/* Tocbot dynamic TOC, works with tocbot 3.0.2 */
44
/* Source: https://github.com/asciidoctor/asciidoctor/issues/699#issuecomment-321066006 */
@@ -11,6 +11,11 @@
1111
.is-collapsible{ max-height:3000px; overflow:hidden; }
1212
.is-collapsed{ max-height:0 }
1313
.is-active-link{ font-weight:700 }
14+
table {
15+
overflow-x: auto;
16+
display: block;
17+
border-width: 0;
18+
}
1419
}
1520
@media print{
1621
#tocbot a.toc-link.node-name--H4{ display:none }

documentation/src/docs/asciidoc/release-notes/release-notes-6.1.0-M1.adoc

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,20 @@ repository on GitHub.
2121
[[release-notes-6.1.0-M1-junit-platform-deprecations-and-breaking-changes]]
2222
==== Deprecations and Breaking Changes
2323

24-
* ❓
24+
* Deprecate constructors for `ForkJoinPoolHierarchicalTestExecutorService` in favor of the
25+
new `ParallelHierarchicalTestExecutorServiceFactory` that also supports
26+
`WorkerThreadPoolHierarchicalTestExecutorService`.
2527

2628
[[release-notes-6.1.0-M1-junit-platform-new-features-and-improvements]]
2729
==== New Features and Improvements
2830

2931
* Support for creating a `ModuleSelector` from a `java.lang.Module` and using
3032
its classloader for test discovery.
33+
* New `WorkerThreadPoolHierarchicalTestExecutorService` implementation used for parallel
34+
test execution that is backed by a regular thread pool rather than a `ForkJoinPool`.
35+
Engine authors should switch to use `ParallelHierarchicalTestExecutorServiceFactory`
36+
rather than instantiating a concrete `HierarchicalTestExecutorService` implementation
37+
for parallel execution directly.
3138
* `OpenTestReportGeneratingListener` now supports redirecting XML events to a socket via
3239
the new `junit.platform.reporting.open.xml.socket` configuration parameter. When set to a
3340
port number, events are sent to `127.0.0.1:<port>` instead of being written to a file.
@@ -63,6 +70,13 @@ repository on GitHub.
6370
* Enrich `assertInstanceOf` failure using the test subject `Throwable` as cause. It
6471
results in the stack trace of the test subject `Throwable` to get reported along with
6572
the failure.
73+
* Make implementation of `HierarchicalTestExecutorService` used for parallel test
74+
execution configurable via the new
75+
`junit.jupiter.execution.parallel.config.executor-service` configuration parameter to
76+
in order to add support for `WorkerThreadPoolHierarchicalTestExecutorService`. Please
77+
refer to the
78+
<<../user-guide/index.adoc#writing-tests-parallel-execution-config-executor-service, User Guide>>
79+
for details.
6680

6781
[[release-notes-6.1.0-M1-junit-vintage]]
6882
=== JUnit Vintage

documentation/src/docs/asciidoc/user-guide/running-tests.adoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,13 +1044,13 @@ expressions can be useful.
10441044
| `+++catalog \| shipping+++`
10451045
| all tests for *catalog* plus all tests for *shipping*
10461046

1047-
| `+++catalog & shipping+++`
1047+
| `+++catalog &amp; shipping+++`
10481048
| all tests for the intersection between *catalog* and *shipping*
10491049

1050-
| `+++product & !end-to-end+++`
1050+
| `+++product &amp; !end-to-end+++`
10511051
| all tests for *product*, but not the _end-to-end_ tests
10521052

1053-
| `+++(micro \| integration) & (product \| shipping)+++`
1053+
| `+++(micro \| integration) &amp; (product \| shipping)+++`
10541054
| all _micro_ or _integration_ tests for *product* or *shipping*
10551055
|===
10561056

documentation/src/docs/asciidoc/user-guide/writing-tests.adoc

Lines changed: 92 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -3433,6 +3433,33 @@ used instead.
34333433
[[writing-tests-parallel-execution-config]]
34343434
==== Configuration
34353435

3436+
[[writing-tests-parallel-execution-config-executor-service]]
3437+
===== Executor Service
3438+
3439+
If parallel execution is enabled, a thread pool is used behind the scenes to execute tests
3440+
concurrently. You can configure which implementation of `HierarchicalTestExecutorService`
3441+
is used be setting the `junit.jupiter.execution.parallel.config.executor-service`
3442+
configuration parameter to one of the following options:
3443+
3444+
`fork_join_pool` (default)::
3445+
Use an executor service that is backed by a `ForkJoinPool` from the JDK. This will cause
3446+
tests to be executed in a `ForkJoinWorkerThread`. In some cases, usages of
3447+
`ForkJoinPool` in test or production code or calls to blocking JDK APIs may cause the
3448+
number of concurrently executing tests to increase. To avoid this situation, please use
3449+
`worker_thread_pool`.
3450+
3451+
`worker_thread_pool` (experimental)::
3452+
Use an executor service that is backed by a regular thread pool and does not create
3453+
additional threads if test or production code uses `ForkJoinPool` or calls a blocking
3454+
API in the JDK.
3455+
3456+
WARNING: Using `worker_thread_pool` is currently an _experimental_ feature. You're invited
3457+
to give it a try and provide feedback to the JUnit team so they can improve and eventually
3458+
<<api-evolution, promote>> this feature.
3459+
3460+
[[writing-tests-parallel-execution-config-strategies]]
3461+
===== Strategies
3462+
34363463
Properties such as the desired parallelism and the maximum pool size can be configured
34373464
using a `{ParallelExecutionConfigurationStrategy}`. The JUnit Platform provides two
34383465
implementations out of the box: `dynamic` and `fixed`. Alternatively, you may implement a
@@ -3464,13 +3491,12 @@ strategy with a factor of `1`. Consequently, the desired parallelism will be equ
34643491
number of available processors/cores.
34653492

34663493
.Parallelism alone does not imply maximum number of concurrent threads
3467-
NOTE: By default JUnit Jupiter does not guarantee that the number of concurrently
3468-
executing tests will not exceed the configured parallelism. For example, when using one
3469-
of the synchronization mechanisms described in the next section, the `ForkJoinPool` that
3470-
is used behind the scenes may spawn additional threads to ensure execution continues with
3471-
sufficient parallelism.
3472-
If you require such guarantees, it is possible to limit the maximum number of concurrent
3473-
threads by controlling the maximum pool size of the `dynamic`, `fixed` and `custom`
3494+
NOTE: By default, JUnit Jupiter does not guarantee that the number of threads used to
3495+
execute test will not exceed the configured parallelism. For example, when using one
3496+
of the synchronization mechanisms described in the next section, the executor service
3497+
implementation may spawn additional threads to ensure execution continues with sufficient
3498+
parallelism. If you require such guarantees, it is possible to limit the maximum number of
3499+
threads by configuring the maximum pool size of the `dynamic`, `fixed` and `custom`
34743500
strategies.
34753501

34763502
[[writing-tests-parallel-execution-config-properties]]
@@ -3479,86 +3505,66 @@ strategies.
34793505
The following table lists relevant properties for configuring parallel execution. See
34803506
<<running-tests-config-params>> for details on how to set such properties.
34813507

3482-
[cols="d,d,a,d"]
3483-
|===
3484-
|Property |Description |Supported Values |Default Value
3485-
3486-
| ```junit.jupiter.execution.parallel.enabled```
3487-
| Enable parallel test execution
3488-
|
3489-
* `true`
3490-
* `false`
3491-
| ```false```
3492-
3493-
| ```junit.jupiter.execution.parallel.mode.default```
3494-
| Default execution mode of nodes in the test tree
3495-
|
3496-
* `concurrent`
3497-
* `same_thread`
3498-
| ```same_thread```
3499-
3500-
| ```junit.jupiter.execution.parallel.mode.classes.default```
3501-
| Default execution mode of top-level classes
3502-
|
3503-
* `concurrent`
3504-
* `same_thread`
3505-
| ```same_thread```
3506-
3507-
| ```junit.jupiter.execution.parallel.config.strategy```
3508-
| Execution strategy for desired parallelism and maximum pool size
3509-
|
3510-
* `dynamic`
3511-
* `fixed`
3512-
* `custom`
3513-
| ```dynamic```
3514-
3515-
| ```junit.jupiter.execution.parallel.config.dynamic.factor```
3516-
| Factor to be multiplied by the number of available processors/cores to determine the
3517-
desired parallelism for the ```dynamic``` configuration strategy
3518-
| a positive decimal number
3519-
| ```1.0```
3520-
3521-
| ```junit.jupiter.execution.parallel.config.dynamic.max-pool-size-factor```
3522-
| Factor to be multiplied by the number of available processors/cores and the value of
3508+
====== General
3509+
3510+
`junit.jupiter.execution.parallel.enabled=true|false`::
3511+
Enable/disable parallel test execution (defaults to `false`).
3512+
3513+
`junit.jupiter.execution.parallel.mode.default=concurrent|same_thread`::
3514+
Default execution mode of nodes in the test tree (defaults to `same_thread`).
3515+
3516+
`junit.jupiter.execution.parallel.mode.classes.default=concurrent|same_thread`::
3517+
Default execution mode of top-level classes (defaults to `same_thread`).
3518+
3519+
`junit.jupiter.execution.parallel.config.executor-service=fork_join_pool|worker_thread_pool`::
3520+
Type of `HierarchicalTestExecutorService` to use for parallel execution (defaults to
3521+
`fork_join_pool`).
3522+
3523+
`junit.jupiter.execution.parallel.config.strategy=dynamic|fixed|custom`::
3524+
Execution strategy for desired parallelism, maximum pool size, etc. (defaults to `dynamic`).
3525+
3526+
====== Dynamic strategy
3527+
3528+
`junit.jupiter.execution.parallel.config.dynamic.factor=decimal`::
3529+
Factor to be multiplied by the number of available processors/cores to determine the
3530+
desired parallelism for the ```dynamic``` configuration strategy.
3531+
Must be a positive decimal number (defaults to `1.0`).
3532+
3533+
`junit.jupiter.execution.parallel.config.dynamic.max-pool-size-factor=decimal`::
3534+
Factor to be multiplied by the number of available processors/cores and the value of
35233535
`junit.jupiter.execution.parallel.config.dynamic.factor` to determine the desired
3524-
parallelism for the ```dynamic``` configuration strategy
3525-
| a positive decimal number, must be greater than or equal to `1.0`
3526-
| 256 + the value of `junit.jupiter.execution.parallel.config.dynamic.factor` multiplied
3527-
by the number of available processors/cores
3528-
3529-
| ```junit.jupiter.execution.parallel.config.dynamic.saturate```
3530-
| Disable saturation of the underlying fork-join pool for the ```dynamic``` configuration
3531-
strategy
3532-
|
3533-
* `true`
3534-
* `false`
3535-
| ```true```
3536-
3537-
| ```junit.jupiter.execution.parallel.config.fixed.parallelism```
3538-
| Desired parallelism for the ```fixed``` configuration strategy
3539-
| a positive integer
3540-
| no default value
3541-
3542-
| ```junit.jupiter.execution.parallel.config.fixed.max-pool-size```
3543-
| Desired maximum pool size of the underlying fork-join pool for the ```fixed```
3544-
configuration strategy
3545-
| a positive integer, must be greater than or equal to `junit.jupiter.execution.parallel.config.fixed.parallelism`
3546-
| 256 + the value of `junit.jupiter.execution.parallel.config.fixed.parallelism`
3547-
3548-
| ```junit.jupiter.execution.parallel.config.fixed.saturate```
3549-
| Disable saturation of the underlying fork-join pool for the ```fixed``` configuration
3550-
strategy
3551-
|
3552-
* `true`
3553-
* `false`
3554-
| ```true```
3555-
3556-
| ```junit.jupiter.execution.parallel.config.custom.class```
3557-
| Fully qualified class name of the _ParallelExecutionConfigurationStrategy_ to be
3558-
used for the ```custom``` configuration strategy
3559-
| for example, _org.example.CustomStrategy_
3560-
| no default value
3561-
|===
3536+
parallelism for the ```dynamic``` configuration strategy.
3537+
Must be a positive decimal number greater than or equal to `1.0` (defaults to 256 plus
3538+
the value of `junit.jupiter.execution.parallel.config.dynamic.factor` multiplied by the
3539+
number of available processors/cores)
3540+
3541+
`junit.jupiter.execution.parallel.config.dynamic.saturate=true|false`::
3542+
Enable/disable saturation of the underlying `ForkJoinPool` for the ```dynamic```
3543+
configuration strategy (defaults to `true`). Only used if
3544+
`junit.jupiter.execution.parallel.config.executor-service` is set to `fork_join_pool`.
3545+
3546+
====== Fixed strategy
3547+
3548+
`junit.jupiter.execution.parallel.config.fixed.parallelism=integer`::
3549+
Desired parallelism for the ```fixed``` configuration strategy (no default value). Must
3550+
be a positive integer.
3551+
3552+
`junit.jupiter.execution.parallel.config.fixed.max-pool-size=integer`::
3553+
Desired maximum pool size of the underlying fork-join pool for the ```fixed```
3554+
configuration strategy. Must be a positive integer greater than or equal to
3555+
`junit.jupiter.execution.parallel.config.fixed.parallelism` (defaults to 256 plus the
3556+
value of `junit.jupiter.execution.parallel.config.fixed.parallelism`).
3557+
3558+
`junit.jupiter.execution.parallel.config.fixed.saturate=true|false`::
3559+
Enable/disable saturation of the underlying `ForkJoinPool` for the ```fixed```
3560+
configuration strategy (defaults to `true`). Only used if
3561+
`junit.jupiter.execution.parallel.config.executor-service` is set to `fork_join_pool`.
3562+
3563+
====== Custom strategy
3564+
3565+
`junit.jupiter.execution.parallel.config.custom.class=classname`::
3566+
Fully qualified class name of the `ParallelExecutionConfigurationStrategy` to be used
3567+
for the ```custom``` configuration strategy (no default value).
35623568

35633569
[[writing-tests-parallel-execution-synchronization]]
35643570
==== Synchronization

documentation/src/test/kotlin/example/KotlinCoroutinesDemo.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,13 @@ import org.junit.jupiter.api.BeforeEach
1414
import org.junit.jupiter.api.Test
1515

1616
// end::user_guide[]
17-
// tag::user_guide[]
17+
// @formatter:off
1818
@Suppress("JUnitMalformedDeclaration")
19+
// tag::user_guide[]
1920
class KotlinCoroutinesDemo {
21+
// end::user_guide[]
22+
// @formatter:on
23+
// tag::user_guide[]
2024
@BeforeEach
2125
fun regularSetUp() {
2226
}

documentation/src/test/resources/junit-platform.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
junit.jupiter.execution.parallel.enabled=true
22
junit.jupiter.execution.parallel.mode.default=concurrent
3+
junit.jupiter.execution.parallel.config.executor-service=worker_thread_pool
34
junit.jupiter.execution.parallel.config.strategy=fixed
45
junit.jupiter.execution.parallel.config.fixed.parallelism=6
56

documentation/src/test/resources/log4j2-test.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
xsi:schemaLocation="https://logging.apache.org/xml/ns https://logging.apache.org/xml/ns/log4j-config-2.xsd">
66
<Appenders>
77
<Console name="Console" target="SYSTEM_OUT">
8-
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
8+
<PatternLayout pattern="%d{HH:mm:ss.SSSSSS} [%-18t] %-5level %logger{1.} - %msg%n"/>
99
</Console>
1010
</Appenders>
1111
<Loggers>

0 commit comments

Comments
 (0)