T - The class used to represent thrown exceptionspublic interface ExceptionTracker<T>
| Modifier and Type | Method and Description |
|---|---|
void |
checkExceptions()
Call this method in a teardown (@After) phase of the test to:
Verify no non-ignored exceptions were thrown
Assert there is an exception matching each of the expected predicates
Implementations should throw an exception and print a summary if the assertion(s) are violated.
|
static <T> ExceptionTracker<T> |
create(@NotNull Function<T,String> messageExtractor,
@NotNull Function<T,Throwable> throwableExtractor,
@NotNull Runnable resetRunnable,
@NotNull Map<T,Integer> exceptions,
@NotNull Predicate<T> ignorePredicate,
@NotNull Function<T,String> exceptionRenderer)
Factory method to create an instance of the exception tracker.
|
void |
expectException(Predicate<T> predicate,
String description)
Specifies that an exception matching the specified predicate must be thrown.
|
void |
expectException(String message)
Specifies that an exception containing the specified string must be thrown during the test.
|
boolean |
hasException(Predicate<T> predicate)
Determines if the tracker contains an exception matching the predicate.
|
boolean |
hasException(String message)
Determines if the tracker contains an exception matching the predicate.
|
void |
ignoreException(Predicate<T> predicate,
String description)
Ignores exceptions matching the specified predicate.
|
void |
ignoreException(String message)
Ignores exceptions containing the specified string.
|
static <T> ExceptionTracker<T> create(@NotNull @NotNull Function<T,String> messageExtractor, @NotNull @NotNull Function<T,Throwable> throwableExtractor, @NotNull @NotNull Runnable resetRunnable, @NotNull @NotNull Map<T,Integer> exceptions, @NotNull @NotNull Predicate<T> ignorePredicate, @NotNull @NotNull Function<T,String> exceptionRenderer)
messageExtractor - Function to extract the String message or description from TthrowableExtractor - Function to extract the Throwable from TresetRunnable - Runnable that will be called at the end of checkExceptions()exceptions - Map to populate with T as the key and count of occurrences as valueignorePredicate - Predicate to exclude T's from considerationexceptionRenderer - Function to render T as a String (used when dumping exceptions)void expectException(String message)
message - The string to requirevoid expectException(Predicate<T> predicate, String description)
predicate - Predicate to match exceptionsdescription - Description of the exceptions being requiredvoid ignoreException(String message)
message - The string to ignorevoid ignoreException(Predicate<T> predicate, String description)
predicate - Predicate to match the exceptiondescription - Description of the exceptions being ignoredboolean hasException(Predicate<T> predicate)
predicate - Predicate to match the exceptionboolean hasException(String message)
message - The exception messagevoid checkExceptions()
Copyright © 2024. All rights reserved.