Skip to content

Commit 5b4d09c

Browse files
committed
Merge remote-tracking branch 'origin/main' into rien/remove-worker-executor-dead-code
2 parents 2a5bea0 + a0d0392 commit 5b4d09c

File tree

30 files changed

+1334
-245
lines changed

30 files changed

+1334
-245
lines changed

documentation/modules/ROOT/pages/writing-tests/assumptions.adoc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,26 @@ references.
1616

1717
All JUnit Jupiter assumptions are static methods in the `{Assumptions}` class.
1818

19+
[tabs]
20+
====
21+
Java::
22+
+
23+
--
1924
[source,java,indent=0]
2025
----
2126
include::example$java/example/AssumptionsDemo.java[tags=user_guide]
2227
----
28+
--
29+
30+
Kotlin::
31+
+
32+
--
33+
[source,kotlin,indent=0]
34+
----
35+
include::example$kotlin/example/kotlin/AssumptionsDemo.kt[tags=user_guide]
36+
----
37+
--
38+
====
2339

2440
NOTE: It is also possible to use methods from JUnit 4's `org.junit.Assume` class for
2541
assumptions. Specifically, JUnit Jupiter supports JUnit 4's `AssumptionViolatedException`

documentation/modules/ROOT/pages/writing-tests/dynamic-tests.adoc

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,26 @@ For demonstration purposes, the `dynamicNodeSingleTest()` method generates a sin
7676
`DynamicTest` instead of a stream, and the `dynamicNodeSingleContainer()` method generates
7777
a nested hierarchy of dynamic tests utilizing `DynamicContainer`.
7878

79-
[source,java]
79+
[tabs]
80+
====
81+
Java::
82+
+
83+
--
84+
[source,java,indent=0]
8085
----
8186
include::example$java/example/DynamicTestsDemo.java[tags=user_guide]
8287
----
88+
--
89+
90+
Kotlin::
91+
+
92+
--
93+
[source,kotlin,indent=0]
94+
----
95+
include::example$kotlin/example/kotlin/DynamicTestsDemo.kt[tags=user_guide]
96+
----
97+
--
98+
====
8399

84100
[[named-support]]
85101
== Dynamic Tests and Named
@@ -90,10 +106,26 @@ shown in the first example below. The second example takes it one step further a
90106
to provide the code block that should be executed by implementing the `Executable`
91107
interface along with `Named` via the `NamedExecutable` base class.
92108

93-
[source,java]
109+
[tabs]
110+
====
111+
Java::
112+
+
113+
--
114+
[source,java,indent=0]
94115
----
95116
include::example$java/example/DynamicTestsNamedDemo.java[tags=user_guide]
96117
----
118+
--
119+
120+
Kotlin::
121+
+
122+
--
123+
[source,kotlin,indent=0]
124+
----
125+
include::example$kotlin/example/kotlin/DynamicTestsNamedDemo.kt[tags=user_guide]
126+
----
127+
--
128+
====
97129

98130
[[uri-test-source]]
99131
== URI Test Sources for Dynamic Tests
@@ -138,10 +170,26 @@ xref:writing-tests/parallel-execution.adoc[parallel execution]. You can configur
138170
`ExecutionMode` by using the `dynamicTest(Consumer)` and `dynamicContainer(Consumer)`
139171
factory methods as illustrated by the following example.
140172

173+
[tabs]
174+
====
175+
Java::
176+
+
177+
--
141178
[source,java,indent=0]
142179
----
143180
include::example$java/example/DynamicTestsDemo.java[tags=execution_mode]
144181
----
182+
--
183+
184+
Kotlin::
185+
+
186+
--
187+
[source,kotlin,indent=0]
188+
----
189+
include::example$kotlin/example/kotlin/DynamicTestsDemo.kt[tags=execution_mode]
190+
----
191+
--
192+
====
145193

146194
Executing the above test factory method results in the following test tree and execution
147195
modes:

documentation/modules/ROOT/pages/writing-tests/exception-handling.adoc

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,26 @@ In the following example, the `failsDueToUncaughtException()` method throws an
2626
`ArithmeticException`. Since the exception is not caught within the test method, JUnit
2727
Jupiter will mark the test as failed.
2828

29+
[tabs]
30+
====
31+
Java::
32+
+
33+
--
2934
[source,java,indent=0]
3035
----
3136
include::example$java/example/exception/UncaughtExceptionHandlingDemo.java[tags=user_guide]
3237
----
38+
--
39+
40+
Kotlin::
41+
+
42+
--
43+
[source,kotlin,indent=0]
44+
----
45+
include::example$kotlin/example/kotlin/exception/UncaughtExceptionHandlingDemo.kt[tags=user_guide]
46+
----
47+
--
48+
====
3349

3450
NOTE: It's important to note that specifying a `throws` clause in the test method has
3551
no effect on the outcome of the test. JUnit Jupiter does not interpret a `throws` clause
@@ -59,10 +75,26 @@ In the following example, the `failsDueToUncaughtAssertionError()` method throws
5975
`AssertionError`. Since the exception is not caught within the test method, JUnit Jupiter
6076
will mark the test as failed.
6177

78+
[tabs]
79+
====
80+
Java::
81+
+
82+
--
6283
[source,java,indent=0]
6384
----
6485
include::example$java/example/exception/FailedAssertionDemo.java[tags=user_guide]
6586
----
87+
--
88+
89+
Kotlin::
90+
+
91+
--
92+
[source,kotlin,indent=0]
93+
----
94+
include::example$kotlin/example/kotlin/exception/FailedAssertionDemo.kt[tags=user_guide]
95+
----
96+
--
97+
====
6698

6799
[[expected]]
68100
== Asserting Expected Exceptions
@@ -81,10 +113,26 @@ type of the thrown exception but also its subclasses, making it suitable for mor
81113
generalized exception handling tests. The `assertThrows()` assertion method returns the
82114
thrown exception object to allow performing additional assertions on it.
83115

116+
[tabs]
117+
====
118+
Java::
119+
+
120+
--
84121
[source,java,indent=0]
85122
----
86123
include::example$java/example/exception/ExceptionAssertionDemo.java[tags=user_guide]
87124
----
125+
--
126+
127+
Kotlin::
128+
+
129+
--
130+
[source,kotlin,indent=0]
131+
----
132+
include::example$kotlin/example/kotlin/exception/ExceptionAssertionDemo.kt[tags=user_guide]
133+
----
134+
--
135+
====
88136

89137
[[expected-assertThrowsExactly]]
90138
=== Using `assertThrowsExactly()`
@@ -95,10 +143,26 @@ exception type. This is useful when precise exception handling behavior needs to
95143
validated. Similar to `assertThrows()`, the `assertThrowsExactly()` assertion method also
96144
returns the thrown exception object to allow performing additional assertions on it.
97145

146+
[tabs]
147+
====
148+
Java::
149+
+
150+
--
98151
[source,java,indent=0]
99152
----
100153
include::example$java/example/exception/ExceptionAssertionExactDemo.java[tags=user_guide]
101154
----
155+
--
156+
157+
Kotlin::
158+
+
159+
--
160+
[source,kotlin,indent=0]
161+
----
162+
include::example$kotlin/example/kotlin/exception/ExceptionAssertionExactDemo.kt[tags=user_guide]
163+
----
164+
--
165+
====
102166

103167
[[not-expected]]
104168
== Asserting That no Exception is Expected
@@ -109,10 +173,26 @@ _not_ thrown for a given code block within a test method. The `assertDoesNotThro
109173
assertion can be used when you want to verify that a particular piece of code does not
110174
throw any exceptions.
111175

176+
[tabs]
177+
====
178+
Java::
179+
+
180+
--
112181
[source,java,indent=0]
113182
----
114183
include::example$java/example/exception/AssertDoesNotThrowExceptionDemo.java[tags=user_guide]
115184
----
185+
--
186+
187+
Kotlin::
188+
+
189+
--
190+
[source,kotlin,indent=0]
191+
----
192+
include::example$kotlin/example/kotlin/exception/AssertDoesNotThrowExceptionDemo.kt[tags=user_guide]
193+
----
194+
--
195+
====
116196

117197
NOTE: Third-party assertion libraries often provide similar support. For example, AssertJ
118198
has `assertThatNoException().isThrownBy(() -> ...)`. See also:

documentation/modules/ROOT/pages/writing-tests/nested-tests.adoc

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,27 @@ several groups of tests. Such nested tests make use of Java's nested classes and
55
facilitate hierarchical thinking about the test structure. Here's an elaborate example,
66
both as source code and as a screenshot of the execution within an IDE.
77

8-
[source,java,indent=0]
98
.Nested test suite for testing a stack
9+
[tabs]
10+
====
11+
Java::
12+
+
13+
--
14+
[source,java,indent=0]
1015
----
1116
include::example$java/example/TestingAStackDemo.java[tags=user_guide]
1217
----
18+
--
19+
20+
Kotlin::
21+
+
22+
--
23+
[source,kotlin,indent=0]
24+
----
25+
include::example$kotlin/example/kotlin/TestingAStackDemo.kt[tags=user_guide]
26+
----
27+
--
28+
====
1329

1430
When executing this example in an IDE, the test execution tree in the GUI will look
1531
similar to the following image.
@@ -39,10 +55,26 @@ class is parameterized.
3955
The following example illustrates how to combine `@Nested` with `@ParameterizedClass` and
4056
`@ParameterizedTest`.
4157

58+
[tabs]
59+
====
60+
Java::
61+
+
62+
--
4263
[source,java,indent=0]
4364
----
4465
include::example$java/example/ParameterizedClassDemo.java[tags=nested]
4566
----
67+
--
68+
69+
Kotlin::
70+
+
71+
--
72+
[source,kotlin,indent=0]
73+
----
74+
include::example$kotlin/example/kotlin/ParameterizedClassDemo.kt[tags=nested]
75+
----
76+
--
77+
====
4678

4779
Executing the above test class yields the following output:
4880

documentation/modules/ROOT/pages/writing-tests/repeated-tests.adoc

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,32 @@ desired. Each invocation of a repeated test behaves like the execution of a regu
88
The following example demonstrates how to declare a test named `repeatedTest()` that
99
will be automatically repeated 10 times.
1010

11+
[tabs]
12+
====
13+
Java::
14+
+
15+
--
1116
[source,java]
1217
----
1318
@RepeatedTest(10)
1419
void repeatedTest() {
1520
// ...
1621
}
1722
----
23+
--
24+
25+
Kotlin::
26+
+
27+
--
28+
[source,kotlin]
29+
----
30+
@RepeatedTest(10)
31+
fun repeatedTest() {
32+
// ...
33+
}
34+
----
35+
--
36+
====
1837

1938
`@RepeatedTest` can be configured with a failure threshold which signifies the number of
2039
failures after which remaining repetitions will be automatically skipped. Set the
@@ -125,10 +144,26 @@ INFO: About to execute repetition 4 of 5 for repeatedTestInGerman
125144
INFO: About to execute repetition 5 of 5 for repeatedTestInGerman
126145
....
127146

128-
[source,java]
147+
[tabs]
148+
====
149+
Java::
150+
+
151+
--
152+
[source,java,indent=0]
129153
----
130154
include::example$java/example/RepeatedTestsDemo.java[tags=user_guide]
131155
----
156+
--
157+
158+
Kotlin::
159+
+
160+
--
161+
[source,kotlin,indent=0]
162+
----
163+
include::example$kotlin/example/kotlin/RepeatedTestsDemo.kt[tags=user_guide]
164+
----
165+
--
166+
====
132167

133168
When using the `ConsoleLauncher` with the unicode theme enabled, execution of
134169
`RepeatedTestsDemo` results in the following output to the console.

documentation/modules/ROOT/pages/writing-tests/test-classes-and-methods.adoc

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,27 @@ lifecycle methods. For further information on runtime semantics, see
4141
xref:writing-tests/test-execution-order.adoc[] and
4242
xref:extensions/relative-execution-order-of-user-code-and-extensions.adoc#wrapping-behavior[Wrapping Behavior of Callbacks].
4343

44+
.A standard test class
45+
[tabs]
46+
====
47+
Java::
48+
+
49+
--
4450
[source,java,indent=0]
45-
.A standard Java test class
4651
----
4752
include::example$java/example/StandardTests.java[tags=user_guide]
4853
----
54+
--
55+
56+
Kotlin::
57+
+
58+
--
59+
[source,kotlin,indent=0]
60+
----
61+
include::example$kotlin/example/kotlin/StandardTests.kt[tags=user_guide]
62+
----
63+
--
64+
====
4965

5066
It is also possible to use Java `record` classes as test classes as illustrated by the
5167
following example.

documentation/modules/ROOT/partials/release-notes/release-notes-6.1.0-M2.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ repository on GitHub.
4747
* Recursive updates are now supported when using `computeIfAbsent(K, Function, Class)` in
4848
the `ExtensionContext.Store`, providing parity with the deprecated
4949
`getOrComputeIfAbsent(K, Function, Class)` method.
50+
* Include index of `@ClassTemplate`/`@ParameterizedClass` invocations in test names in
51+
legacy XML reports to make them unique
5052

5153
[[v6.1.0-M2-junit-jupiter-deprecations-and-breaking-changes]]
5254
==== Deprecations and Breaking Changes

0 commit comments

Comments
 (0)