Skip to content

Commit 3fdbe6d

Browse files
authored
Merge branch 'main' into origin/issues/3107-method-filters
2 parents c58bebd + ed8038c commit 3fdbe6d

File tree

20 files changed

+302
-217
lines changed

20 files changed

+302
-217
lines changed
Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
[[release-notes-5.10.0-RC1]]
22
== 5.10.0-RC1
33

4-
*Date of Release:*
4+
*Date of Release:* July ❓, 2023
55

6-
*Scope:* ❓
6+
*Scope:*
7+
8+
* New `@SelectMethod` support in test `@Suite` classes.
9+
* Various enhancements for discovery selectors for classes and methods, including
10+
additional support for custom ClassLoader arrangements.
11+
* Improved `@TempDir` support for cleaning up files and directories on Windows.
12+
* Revised stack trace pruning support.
13+
* Various documentation improvements.
14+
* Minor changes and enhancements since 5.10 M1.
715

816
For a complete list of all _closed_ issues and pull requests for this release, consult the
917
link:{junit5-repo}+/milestone/69?closed=1+[5.10.0-RC1] milestone page in the
@@ -13,10 +21,6 @@ JUnit repository on GitHub.
1321
[[release-notes-5.10.0-RC1-junit-platform]]
1422
=== JUnit Platform
1523

16-
==== Bug Fixes
17-
18-
* ❓
19-
2024
==== Deprecations and Breaking Changes
2125

2226
* The `getMethodParameterTypes()` methods in `MethodSelector` and `NestedMethodSelector`
@@ -33,46 +37,34 @@ JUnit repository on GitHub.
3337
* New `selectMethod()` and `selectNestedMethod()` variants in `DiscoverySelectors` that
3438
accept a `Class<?>...` argument of parameter types as a type-safe alternative to
3539
providing the names of parameter types as a comma-delimited string.
40+
* Stack trace pruning has been revised and now only removes calls from the `org.junit`,
41+
`jdk.internal.reflect`, and `sun.reflect` packages. Please refer to the
42+
<<../user-guide/index.adoc#stacktrace-pruning, User Guide>> for details.
43+
* New `getAncestors()` method in `TestDescriptor`.
3644

3745

3846
[[release-notes-5.10.0-RC1-junit-jupiter]]
3947
=== JUnit Jupiter
4048

41-
==== Bug Fixes
42-
43-
* ❓
44-
45-
==== Deprecations and Breaking Changes
46-
47-
* ❓
48-
4949
==== New Features and Improvements
5050

5151
* `@TempDir` can now be used as a meta-annotation in order to create custom _composed
5252
annotations_. See the `@JimfsTempDir` example in the
5353
<<../user-guide/index.adoc#writing-tests-built-in-extensions-TempDirectory, User Guide>>
5454
for details.
55-
* Lifecycle and thread-safety semantics are now documented for the `TempDirFactory` SPI.
55+
* `@TempDir` now successfully cleans up files and directories on Windows that are set to
56+
read-only.
5657
* New `reason` attribute in `@Execution` which can be used to document the reason for
5758
using the selected execution mode.
5859
* The <<../user-guide/index.adoc#extensions-RandomNumberExtension, User Guide>> now
5960
includes an example implementation of the `RandomNumberExtension` in order to improve
6061
the documentation for extension registration via `@ExtendWith` on fields.
62+
* Lifecycle and thread-safety semantics are now documented for the `TempDirFactory` SPI.
6163
* The scope of applicability for `TestWatcher` implementations is now more extensively
6264
documented in the User Guide and Javadoc.
6365

6466

6567
[[release-notes-5.10.0-RC1-junit-vintage]]
6668
=== JUnit Vintage
6769

68-
==== Bug Fixes
69-
70-
* ❓
71-
72-
==== Deprecations and Breaking Changes
73-
74-
* ❓
75-
76-
==== New Features and Improvements
77-
78-
* ❓
70+
No changes.

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ tests to JUnit Jupiter.
6363
* `@Rule` and `@ClassRule` no longer exist; superseded by `@ExtendWith` and
6464
`@RegisterExtension`.
6565
- See also <<migrating-from-junit4-rule-support>>.
66+
* `@Test(expected = ...)` and the `ExpectedException` rule no longer exist; use
67+
`Assertions.assertThrows(...)` instead.
68+
- See <<migrating-from-junit4-rule-support>> if you still need to use
69+
`ExpectedException`.
6670
* Assertions and assumptions in JUnit Jupiter accept the failure message as their last
6771
argument instead of the first one.
6872
- See <<migrating-from-junit4-failure-message-arguments>> for details.

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

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,24 +1132,20 @@ give it a try and provide feedback to the JUnit team so they can improve and eve
11321132
<<api-evolution, promote>> this feature.
11331133

11341134
[[stacktrace-pruning]]
1135-
=== Stack trace pruning
1135+
=== Stack Trace Pruning
11361136

11371137
Since version 1.10, the JUnit Platform provides built-in support for pruning stack traces
1138-
produced by failing tests. This feature can be enabled or disabled via the
1139-
`junit.platform.stacktrace.pruning.enabled` _configuration parameter_.
1138+
produced by failing tests. This feature is enabled by default but can be disabled by
1139+
setting the `junit.platform.stacktrace.pruning.enabled` _configuration parameter_ to
1140+
`false`.
11401141

1141-
By default, all calls from the `org.junit`, `java`, and `jdk` packages are removed from the
1142-
stack trace. You can also configure the JUnit Platform to exclude different or additional
1143-
calls. To do this, provide a pattern for the `junit.platform.stacktrace.pruning.pattern`
1144-
_configuration parameter_ to specify which fully qualified class names should be excluded
1145-
from the stack traces.
1142+
When enabled, all calls from the `org.junit`, `jdk.internal.reflect`, and `sun.reflect`
1143+
packages are removed from the stack trace, unless the calls occur after the test itself
1144+
or any of its ancestors. For that reason, calls to `{Assertions}` or `{Assumptions}` will
1145+
never be excluded.
11461146

1147-
In addition, and independently of the provided pattern, all elements prior to and
1148-
including the first call from the JUnit Platform Launcher will be removed.
1149-
1150-
NOTE: Since they provide necessary insights to understand a test failure, calls to
1151-
`{Assertions}` or `{Assumptions}` will never be excluded from stack traces even though
1152-
they are part of the `org.junit` package.
1147+
In addition, all elements prior to and including the first call from the JUnit Platform
1148+
Launcher will be removed.
11531149

11541150
[[stacktrace-pruning-pattern]]
11551151
==== Pattern Matching Syntax

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2302,11 +2302,11 @@ might conflict with the configured execution order. Thus, in both cases, test me
23022302
such test classes are only executed concurrently if the `@Execution(CONCURRENT)`
23032303
annotation is present on the test class or method.
23042304

2305-
When parallel execution is enabled and a default `{ClassOrderer}` (see
2306-
<<writing-tests-test-execution-order-classes>> for details) is registered, top-level test
2307-
classes will initially be sorted accordingly and scheduled in that order. However, they
2308-
are not guaranteed to be started in exactly that order since the threads they are executed
2309-
on are not controlled directly by JUnit.
2305+
When parallel execution is enabled and a default `{ClassOrderer}` is registered (see
2306+
<<writing-tests-test-execution-order-classes>> for details), top-level test classes will
2307+
initially be sorted accordingly and scheduled in that order. However, they are not
2308+
guaranteed to be started in exactly that order since the threads they are executed on are
2309+
not controlled directly by JUnit.
23102310

23112311
All nodes of the test tree that are configured with the `CONCURRENT` execution mode will
23122312
be executed fully in parallel according to the provided

gradle/plugins/common/src/main/kotlin/junitbuild.testing-conventions.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ tasks.withType<Test>().configureEach {
4141
server.set(uri("https://ge.junit.org"))
4242
}
4343
systemProperty("java.util.logging.manager", "org.apache.logging.log4j.jul.LogManager")
44-
systemProperty("junit.platform.stacktrace.pruning.enabled", false)
4544
// Required until ASM officially supports the JDK 14
4645
systemProperty("net.bytebuddy.experimental", true)
4746
if (buildParameters.testing.enableJFR) {

gradle/wrapper/gradle-wrapper.jar

93 Bytes
Binary file not shown.

gradle/wrapper/gradle-wrapper.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionSha256Sum=0906569bf96e8ebefbc1aa56318c74aeafd9710455b2817c70d709c5d77785c4
4-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-rc-2-bin.zip
3+
distributionSha256Sum=38f66cd6eef217b4c35855bb11ea4e9fbc53594ccccb5fb82dfd317ef8c2c5a3
4+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
55
networkTimeout=10000
66
validateDistributionUrl=true
77
zipStoreBase=GRADLE_USER_HOME

junit-jupiter-api/src/main/java/org/junit/jupiter/api/condition/JRE.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@
3737
* @see #JAVA_12
3838
* @see #JAVA_13
3939
* @see #JAVA_14
40+
* @see #JAVA_15
41+
* @see #JAVA_16
42+
* @see #JAVA_17
43+
* @see #JAVA_18
44+
* @see #JAVA_19
45+
* @see #JAVA_20
46+
* @see #JAVA_21
4047
* @see #OTHER
4148
* @see EnabledOnJre
4249
* @see DisabledOnJre
@@ -139,7 +146,7 @@ public enum JRE {
139146
JAVA_20,
140147

141148
/**
142-
* Java 20.
149+
* Java 21.
143150
*
144151
* @since 5.9.2
145152
*/
@@ -221,14 +228,16 @@ private static JRE determineCurrentVersion() {
221228

222229
/**
223230
* @return {@code true} if <em>this</em> {@code JRE} is known to be the
224-
* Java Runtime Environment version for the currently executing JVM
231+
* Java Runtime Environment version for the currently executing JVM or if
232+
* the version is {@link #OTHER}
225233
*/
226234
public boolean isCurrentVersion() {
227235
return this == CURRENT_VERSION;
228236
}
229237

230238
/**
231-
* @return the {@link JRE} for the currently executing JVM
239+
* @return the {@link JRE} for the currently executing JVM, potentially
240+
* {@link #OTHER}
232241
*
233242
* @since 5.7
234243
*/

junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/extension/TempDirectory.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import java.nio.file.Paths;
3434
import java.nio.file.SimpleFileVisitor;
3535
import java.nio.file.attribute.BasicFileAttributes;
36+
import java.nio.file.attribute.DosFileAttributeView;
3637
import java.util.Collections;
3738
import java.util.HashSet;
3839
import java.util.Set;
@@ -390,6 +391,15 @@ private static void tryToResetPermissions(Path path) {
390391
if (Files.isDirectory(path)) {
391392
file.setExecutable(true);
392393
}
394+
DosFileAttributeView dos = Files.getFileAttributeView(path, DosFileAttributeView.class);
395+
if (dos != null) {
396+
try {
397+
dos.setReadOnly(false);
398+
}
399+
catch (IOException ignore) {
400+
// nothing we can do
401+
}
402+
}
393403
}
394404

395405
private IOException createIOExceptionWithAttachedFailures(SortedMap<Path, IOException> failures) {

junit-jupiter-engine/src/test/java/org/junit/jupiter/engine/extension/TempDirectoryPerContextTests.java

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import java.io.IOException;
3131
import java.nio.file.Files;
3232
import java.nio.file.Path;
33+
import java.nio.file.attribute.DosFileAttributeView;
3334
import java.util.Deque;
3435
import java.util.LinkedList;
3536
import java.util.function.Supplier;
@@ -47,8 +48,6 @@
4748
import org.junit.jupiter.api.TestInfo;
4849
import org.junit.jupiter.api.TestInstance;
4950
import org.junit.jupiter.api.TestMethodOrder;
50-
import org.junit.jupiter.api.condition.DisabledOnOs;
51-
import org.junit.jupiter.api.condition.OS;
5251
import org.junit.jupiter.api.extension.ExtensionConfigurationException;
5352
import org.junit.jupiter.api.extension.ExtensionContext;
5453
import org.junit.jupiter.api.extension.ParameterResolutionException;
@@ -126,15 +125,13 @@ void nonMintPermissionsDoNotCauseFailure() {
126125
}
127126

128127
@Test
129-
@DisabledOnOs(OS.WINDOWS)
130128
@DisplayName("is capable of removing a read-only file in a read-only dir")
131129
void readOnlyFileInReadOnlyDirDoesNotCauseFailure() {
132130
executeTestsForClass(ReadOnlyFileInReadOnlyDirDoesNotCauseFailureTestCase.class).testEvents()//
133131
.assertStatistics(stats -> stats.started(1).succeeded(1));
134132
}
135133

136134
@Test
137-
@DisabledOnOs(OS.WINDOWS)
138135
@DisplayName("is capable of removing a read-only file in a dir in a read-only dir")
139136
void readOnlyFileInNestedReadOnlyDirDoesNotCauseFailure() {
140137
executeTestsForClass(ReadOnlyFileInDirInReadOnlyDirDoesNotCauseFailureTestCase.class).testEvents()//
@@ -942,8 +939,8 @@ static class ReadOnlyFileInReadOnlyDirDoesNotCauseFailureTestCase {
942939
void createReadOnlyFileInReadOnlyDir(@TempDir File tempDir) throws IOException {
943940
File file = tempDir.toPath().resolve("file").toFile();
944941
assumeTrue(file.createNewFile());
945-
assumeTrue(tempDir.setReadOnly());
946-
assumeTrue(file.setReadOnly());
942+
assumeTrue(makeReadOnly(tempDir));
943+
assumeTrue(makeReadOnly(file));
947944
}
948945

949946
}
@@ -956,13 +953,22 @@ void createReadOnlyFileInReadOnlyDir(@TempDir File tempDir) throws IOException {
956953
File file = tempDir.toPath().resolve("dir").resolve("file").toFile();
957954
assumeTrue(file.getParentFile().mkdirs());
958955
assumeTrue(file.createNewFile());
959-
assumeTrue(tempDir.setReadOnly());
960-
assumeTrue(file.getParentFile().setReadOnly());
961-
assumeTrue(file.setReadOnly());
956+
assumeTrue(makeReadOnly(tempDir));
957+
assumeTrue(makeReadOnly(file.getParentFile()));
958+
assumeTrue(makeReadOnly(file));
962959
}
963960

964961
}
965962

963+
private static boolean makeReadOnly(File file) throws IOException {
964+
var dos = Files.getFileAttributeView(file.toPath(), DosFileAttributeView.class);
965+
if (dos != null) {
966+
dos.setReadOnly(true);
967+
return true;
968+
}
969+
return file.setReadOnly();
970+
}
971+
966972
// https://github.com/junit-team/junit5/issues/2609
967973
@SuppressWarnings("ResultOfMethodCallIgnored")
968974
static class NonMintPermissionContentInTempDirectoryDoesNotCauseFailureTestCase {

0 commit comments

Comments
 (0)