Created
June 27, 2019 17:54
-
-
Save tomwhoiscontrary/a6991ddcbe19b560b265ec97ddf71969 to your computer and use it in GitHub Desktop.
The raises matcher
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static Matcher<Callable<?>> raises(Matcher<? super Throwable> sub) { | |
return new FeatureMatcher<Callable<?>, Throwable>(sub, "thrown exception", "thrown exception") { | |
@Override | |
protected Throwable featureValueOf(Callable<?> thing) { | |
try { | |
thing.call(); | |
} catch (Throwable e) { | |
return e; | |
} | |
return null; | |
} | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment