Skip to content

Commit 2aaf24c

Browse files
cj81499marcphilipp
andauthored
Improve debug mode detection in JUnit Jupiter (#2973)
Co-authored-by: Marc Philipp <[email protected]>
1 parent be55668 commit 2aaf24c

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -2177,7 +2177,8 @@ JUnit Jupiter supports the `junit.jupiter.execution.timeout.mode` configuration
21772177
to configure when timeouts are applied. There are three modes: `enabled`, `disabled`,
21782178
and `disabled_on_debug`. The default mode is `enabled`.
21792179
A VM runtime is considered to run in debug mode when one of its input parameters starts
2180-
with `-agentlib:jdwp`. This heuristic is queried by the `disabled_on_debug` mode.
2180+
with `-agentlib:jdwp` or `-Xrunjdwp`.
2181+
This heuristic is queried by the `disabled_on_debug` mode.
21812182

21822183

21832184
[[writing-tests-parallel-execution]]

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

+4-10
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,10 @@ private RuntimeUtils() {
4040
* Try to determine whether the VM was started in debug mode or not.
4141
*/
4242
public static boolean isDebugMode() {
43-
Optional<List<String>> optionalArguments = getInputArguments();
44-
if (!optionalArguments.isPresent()) {
45-
return false;
46-
}
47-
for (String argument : optionalArguments.get()) {
48-
if (argument.startsWith("-agentlib:jdwp")) {
49-
return true;
50-
}
51-
}
52-
return false;
43+
return getInputArguments() //
44+
.map(args -> args.stream().anyMatch(
45+
arg -> arg.startsWith("-agentlib:jdwp") || arg.startsWith("-Xrunjdwp"))) //
46+
.orElse(false);
5347
}
5448

5549
/**

0 commit comments

Comments
 (0)