Package org.junit.internal
Class Throwables
java.lang.Object
org.junit.internal.Throwables
Miscellaneous functions dealing with
Throwable.- Since:
- 4.12
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static voidappendStackTraceLines(List<String> stackTraceLines, StringBuilder destBuilder) private static <T> List<T> asReversedList(List<T> list) getCauseStackTraceLines(Throwable exception) private static StringgetFullStackTrace(Throwable exception) static StringgetStacktrace(Throwable exception) Returns the stacktrace of the given Throwable as a String.static StringgetTrimmedStackTrace(Throwable exception) Gets a trimmed version of the stack trace of the given exception.getTrimmedStackTraceLines(Throwable exception) private static booleanhasSuppressed(Throwable exception) private static Methodprivate static booleanisMatchingMethod(String methodName, String[] methodNamePrefixes) private static booleanisReflectionMethod(String methodName) private static booleanisTestFrameworkMethod(String methodName) private static <T extends Throwable>
voidstatic ExceptionRethrows the givenThrowable, allowing the caller to declare that it throwsException.
-
Field Details
-
getSuppressed
-
TEST_FRAMEWORK_METHOD_NAME_PREFIXES
-
TEST_FRAMEWORK_TEST_METHOD_NAME_PREFIXES
-
REFLECTION_METHOD_NAME_PREFIXES
-
-
Constructor Details
-
Throwables
private Throwables()
-
-
Method Details
-
rethrowAsException
Rethrows the givenThrowable, allowing the caller to declare that it throwsException. This is useful when your callers have nothing reasonable they can do when aThrowableis thrown. This is declared to returnExceptionso it can be used in athrowclause:try { doSomething(); } catch (Throwable e} { throw Throwables.rethrowAsException(e); } doSomethingLater();- Parameters:
e- exception to rethrow- Returns:
- does not return anything
- Throws:
Exception- Since:
- 4.12
-
rethrow
- Throws:
T
-
getStacktrace
Returns the stacktrace of the given Throwable as a String.- Since:
- 4.13
-
getTrimmedStackTrace
Gets a trimmed version of the stack trace of the given exception. Stack trace elements that are below the test method are filtered out.- Returns:
- a trimmed stack trace, or the original trace if trimming wasn't possible
-
getTrimmedStackTraceLines
-
initGetSuppressed
-
hasSuppressed
-
getCauseStackTraceLines
-
getFullStackTrace
-
appendStackTraceLines
-
asReversedList
-
isTestFrameworkMethod
-
isReflectionMethod
-
isMatchingMethod
-