Skip to content

Commit 1f36bc8

Browse files
committed
Polishing
1 parent 607e028 commit 1f36bc8

File tree

5 files changed

+36
-30
lines changed

5 files changed

+36
-30
lines changed

documentation/src/docs/asciidoc/release-notes/release-notes-5.10.0-RC1.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ JUnit repository on GitHub.
3838
<<../user-guide/index.adoc#stacktrace-pruning, User Guide>> for details.
3939
* New `getAncestors()` method in `TestDescriptor`.
4040

41+
4142
[[release-notes-5.10.0-RC1-junit-jupiter]]
4243
=== JUnit Jupiter
4344

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,14 +1132,15 @@ 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-
If enabled, all calls from the `org.junit`, `jdk.internal.reflect`, and `sun.reflect`
1142-
packages are removed from the stack trace, unless they are subsequent to the test itself
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
11431144
or any of its ancestors. For that reason, calls to `{Assertions}` or `{Assumptions}` will
11441145
never be excluded.
11451146

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

junit-platform-commons/src/main/java/org/junit/platform/commons/util/ExceptionUtils.java

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -96,24 +96,25 @@ public static String readStackTrace(Throwable throwable) {
9696

9797
/**
9898
* Prune the stack trace of the supplied {@link Throwable} by removing
99-
* elements from the {@code org.junit}, {@code jdk.internal.reflect} and
100-
* {@code sun.reflect} packages. If an element matching one of the supplied
101-
* class names is encountered, all following elements will be kept regardless.
99+
* {@linkplain StackTraceElement stack trace elements} from the {@code org.junit},
100+
* {@code jdk.internal.reflect}, and {@code sun.reflect} packages. If a
101+
* {@code StackTraceElement} matching one of the supplied {@code classNames}
102+
* is encountered, all subsequent elements in the stack trace will be retained.
102103
*
103-
* <p>Additionally, all elements prior to and including the first
104-
* JUnit Launcher call will be removed.
104+
* <p>Additionally, all elements prior to and including the first JUnit Platform
105+
* Launcher call will be removed.
105106
*
106-
* @param throwable the {@code Throwable} whose stack trace should be
107-
* pruned; never {@code null}
108-
* @param testClassNames the test class names that should stop the pruning
109-
* if encountered; never {@code null}
107+
* @param throwable the {@code Throwable} whose stack trace should be pruned;
108+
* never {@code null}
109+
* @param classNames the class names that should stop the pruning if encountered;
110+
* never {@code null}
110111
*
111-
* @since 5.10
112+
* @since 1.10
112113
*/
113-
@API(status = INTERNAL, since = "5.10")
114-
public static void pruneStackTrace(Throwable throwable, List<String> testClassNames) {
114+
@API(status = INTERNAL, since = "1.10")
115+
public static void pruneStackTrace(Throwable throwable, List<String> classNames) {
115116
Preconditions.notNull(throwable, "Throwable must not be null");
116-
Preconditions.notNull(testClassNames, "List of test class names must not be null");
117+
Preconditions.notNull(classNames, "List of class names must not be null");
117118

118119
List<StackTraceElement> stackTrace = Arrays.asList(throwable.getStackTrace());
119120
List<StackTraceElement> prunedStackTrace = new ArrayList<>();
@@ -124,7 +125,7 @@ public static void pruneStackTrace(Throwable throwable, List<String> testClassNa
124125
StackTraceElement element = stackTrace.get(i);
125126
String className = element.getClassName();
126127

127-
if (testClassNames.contains(className)) {
128+
if (classNames.contains(className)) {
128129
// Include all elements called by the test
129130
prunedStackTrace.addAll(stackTrace.subList(i, stackTrace.size()));
130131
break;
@@ -142,16 +143,16 @@ else if (STACK_TRACE_ELEMENT_FILTER.test(className)) {
142143
}
143144

144145
/**
145-
* Find all causes and suppressed exceptions in the backtrace of the
146+
* Find all causes and suppressed exceptions in the stack trace of the
146147
* supplied {@link Throwable}.
147148
*
148149
* @param rootThrowable the {@code Throwable} to explore; never {@code null}
149150
* @return an immutable list of all throwables found, including the supplied
150151
* one; never {@code null}
151152
*
152-
* @since 5.10
153+
* @since 1.10
153154
*/
154-
@API(status = INTERNAL, since = "5.10")
155+
@API(status = INTERNAL, since = "1.10")
155156
public static List<Throwable> findNestedThrowables(Throwable rootThrowable) {
156157
Preconditions.notNull(rootThrowable, "Throwable must not be null");
157158

junit-platform-engine/src/main/java/org/junit/platform/engine/TestDescriptor.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ default String getLegacyReportingName() {
109109
/**
110110
* Get the immutable set of all <em>ancestors</em> of this descriptor.
111111
*
112-
* <p>An <em>ancestors</em> is the parent of this descriptor or the parent
113-
* of one of its parents, recursively.
112+
* <p>An <em>ancestor</em> is the parent of this descriptor or the parent of
113+
* one of its parents, recursively.
114114
*
115115
* @see #getParent()
116116
*/
@@ -122,7 +122,10 @@ default Set<? extends TestDescriptor> getAncestors() {
122122
TestDescriptor parent = getParent().get();
123123
Set<TestDescriptor> ancestors = new LinkedHashSet<>();
124124
ancestors.add(parent);
125-
ancestors.addAll(parent.getAncestors());
125+
// Need to recurse?
126+
if (parent.getParent().isPresent()) {
127+
ancestors.addAll(parent.getAncestors());
128+
}
126129
return Collections.unmodifiableSet(ancestors);
127130
}
128131

0 commit comments

Comments
 (0)