Skip to content

Commit

Permalink
Add system property to disable stack trace trimming.
Browse files Browse the repository at this point in the history
This can be set by tools that cannot handle the trmmed stack traces.
  • Loading branch information
kcooney committed Jan 23, 2017
1 parent 937f0de commit 436788a
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/main/java/org/junit/runner/notification/Failure.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/
public class Failure implements Serializable {
private static final long serialVersionUID = 1L;
private static final boolean disableStackTraceTrimming = readDisableStackTraceTrimmingPreference();

/*
* We have to use the f prefix until the next major release to ensure
Expand All @@ -35,11 +36,19 @@ public class Failure implements Serializable {
public Failure(Description description, Throwable thrownException) {
this.fThrownException = thrownException;
this.fDescription = description;
if (thrownException != null) {
if (!disableStackTraceTrimming && thrownException != null) {
StackTraces.trimStackTrace(thrownException);
}
}

private static boolean readDisableStackTraceTrimmingPreference() {
try {
return Boolean.getBoolean("org.junit.junit4.disable-stacktrace-trimming");
} catch (SecurityException e) {
return true;
}
}

/**
* @return a user-understandable label for the test
*/
Expand Down

0 comments on commit 436788a

Please sign in to comment.