Skip to content

Commit

Permalink
Extract and document Launcher constants
Browse files Browse the repository at this point in the history
  • Loading branch information
juliette-derancourt committed May 5, 2023
1 parent a09bc1e commit 45d16de
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,59 @@ public class LauncherConstants {
@API(status = EXPERIMENTAL, since = "1.10")
public static final String DRY_RUN_PROPERTY_NAME = "junit.platform.execution.dryRun.enabled";

/**
* Property name used to enable or disable stack trace pruning.
*
* <p>By default, stack trace pruning is enabled.
*
* @see org.junit.platform.launcher.core.EngineExecutionOrchestrator
*/
@API(status = EXPERIMENTAL, since = "1.10")
public static final String STACKTRACE_PRUNING_ENABLED_PROPERTY_NAME = "junit.platform.stacktrace.pruning.enabled";

/**
* Property name used to provide patterns to remove elements from stack traces.
*
* <h4>Pattern Matching Syntax</h4>
*
* <p>If the property value consists solely of an asterisk ({@code *}), all
* elements will be removed. Otherwise, the property value will be treated
* as a comma-separated list of patterns where each individual pattern will be
* matched against the fully qualified class name (<em>FQCN</em>) of the stack trace
* element. Any dot ({@code .}) in a pattern will match against a dot ({@code .})
* or a dollar sign ({@code $}) in a FQCN. Any asterisk ({@code *}) will match
* against one or more characters in a FQCN. All other characters in a pattern
* will be matched one-to-one against a FQCN.
*
* <h4>Examples</h4>
*
* <ul>
* <li>{@code *}: remove all elements.
* <li>{@code org.junit.*}: remove every element with the {@code org.junit}
* base package and any of its subpackages.
* <li>{@code *.MyClass}: remove every element whose simple class name is
* exactly {@code MyClass}.
* <li>{@code *System*, *Dev*}: exclude every element whose FQCN contains
* {@code System} or {@code Dev}.
* <li>{@code org.example.MyClass, org.example.TheirClass}: remove
* elements whose FQCN is exactly {@code org.example.MyClass} or
* {@code org.example.TheirClass}.
* </ul>
*
* @see #STACKTRACE_PRUNING_DEFAULT_PATTERN
*/
@API(status = EXPERIMENTAL, since = "1.10")
public static final String STACKTRACE_PRUNING_PATTERN_PROPERTY_NAME = "junit.platform.stacktrace.pruning.pattern";

/**
* Default pattern for stack trace pruning which matches {@code org.junit},
* {@code java} and {@code jdk} base packages, and any of their subpackages.
*
* @see #STACKTRACE_PRUNING_PATTERN_PROPERTY_NAME
*/
@API(status = EXPERIMENTAL, since = "1.10")
public static final String STACKTRACE_PRUNING_DEFAULT_PATTERN = "org.junit.*,java.*";

private LauncherConstants() {
/* no-op */
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@

import static org.apiguardian.api.API.Status.INTERNAL;
import static org.junit.platform.launcher.LauncherConstants.DRY_RUN_PROPERTY_NAME;
import static org.junit.platform.launcher.LauncherConstants.STACKTRACE_PRUNING_DEFAULT_PATTERN;
import static org.junit.platform.launcher.LauncherConstants.STACKTRACE_PRUNING_ENABLED_PROPERTY_NAME;
import static org.junit.platform.launcher.LauncherConstants.STACKTRACE_PRUNING_PATTERN_PROPERTY_NAME;
import static org.junit.platform.launcher.core.ListenerRegistry.forEngineExecutionListeners;
import static org.junit.platform.launcher.core.StackTracePruningEngineExecutionListener.STACKTRACE_PRUNING_DEFAULT_PATTERN;
import static org.junit.platform.launcher.core.StackTracePruningEngineExecutionListener.STACKTRACE_PRUNING_ENABLED_PROPERTY_NAME;
import static org.junit.platform.launcher.core.StackTracePruningEngineExecutionListener.STACKTRACE_PRUNING_PATTERN_PROPERTY_NAME;

import java.util.Optional;
import java.util.function.Consumer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@
*/
class StackTracePruningEngineExecutionListener extends DelegatingEngineExecutionListener {

public static final String STACKTRACE_PRUNING_ENABLED_PROPERTY_NAME = "junit.platform.stacktrace.pruning.enabled";
public static final String STACKTRACE_PRUNING_PATTERN_PROPERTY_NAME = "junit.platform.stacktrace.pruning.pattern";
public static final String STACKTRACE_PRUNING_DEFAULT_PATTERN = "org.junit.*,java.*";
private static final List<String> ALWAYS_INCLUDED_STACK_TRACE_ELEMENTS = Arrays.asList( //
"org.junit.jupiter.api.Assertions", //
"org.junit.jupiter.api.Assumptions" //
Expand Down

0 comments on commit 45d16de

Please sign in to comment.