/** * Throws an {@link AssertionError} with a message explaining that a {@link Throwable} of given class was expected to be thrown * but had not been. * * @param <T> dummy return value type * @param throwableClass the Throwable class that was expected to be thrown. * @return nothing, it's just to be used in doSomething(optional.orElse(() -> shouldHaveThrown(IOException.class)));. * @throws AssertionError with a message explaining that a {@link Throwable} of given class was expected to be thrown but had * not been. */ public static <T> T shouldHaveThrown(Class<? extends Throwable> throwableClass) { throw Failures.instance().expectedThrowableNotThrown(throwableClass); }
/** * Throws an {@link AssertionError} with a message explaining that a {@link Throwable} of given class was expected to be thrown * but had not been. * * @param <T> dummy return value type * @param throwableClass the Throwable class that was expected to be thrown. * @return nothing, it's just to be used in doSomething(optional.orElse(() -> shouldHaveThrown(IOException.class)));. * @throws AssertionError with a message explaining that a {@link Throwable} of given class was expected to be thrown but had * not been. */ public static <T> T shouldHaveThrown(Class<? extends Throwable> throwableClass) { throw Failures.instance().expectedThrowableNotThrown(throwableClass); }
/** * Fails with a message explaining that a {@link Throwable} of given class was expected to be thrown * but had not been. * * @param throwableClass the Throwable class that was expected to be thrown. * @throws AssertionError with a message explaining that a {@link Throwable} of given class was expected to be thrown but had * not been. * @since 2.6.0 / 3.6.0 */ public void shouldHaveThrown(Class<? extends Throwable> throwableClass) { AssertionError error = Failures.instance().expectedThrowableNotThrown(throwableClass); proxies.collectError(error); }
/** * Fails with a message explaining that a {@link Throwable} of given class was expected to be thrown * but had not been. * * @param throwableClass the Throwable class that was expected to be thrown. * @throws AssertionError with a message explaining that a {@link Throwable} of given class was expected to be thrown but had * not been. * @since 2.6.0 / 3.6.0 */ public void shouldHaveThrown(Class<? extends Throwable> throwableClass) { AssertionError error = Failures.instance().expectedThrowableNotThrown(throwableClass); proxies.collectError(error); }