public class FluentExpectedException extends Object
ThrowableAssert.
Usage in tests:
@Rule
public FluentExpectedException thrown = FluentExpectedException.none();
@Test
public void fluent_rule_any_exception() {
thrown.expect().hasMessage("exc").hasNoCause();
throw new IllegalStateException("exc");
}
| Modifier | Constructor and Description |
|---|---|
protected |
FluentExpectedException()
Create new instance of
FluentExpectedException rule. |
protected |
FluentExpectedException(ProxiesFactory proxiesFactory)
Create new instance of
FluentExpectedException rule. |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addCheck(Check check)
Add assertion callback to callback list.
|
Statement |
apply(Statement base,
Description description)
Method required by junit from rules implementations.
|
ThrowableAssert |
expect()
Starts expecting of any exception.
|
ThrowableAssert |
expect(Class<? extends Throwable> type)
Starts expecting of exception of specified type.
|
ThrowableAssert |
expectCause()
Start expecting of exception with any cause.
|
ThrowableAssert |
expectCause(Class<? extends Throwable> type)
Starts expecting of exception with cause of specified type.
|
<A extends AbstractThrowableAssert<A,T>,T extends Throwable> |
expectCauseWith(Class<A> assertClass) |
ThrowableAssert |
expectRootCause()
Starts expecting of exception with any root cause.
|
ThrowableAssert |
expectRootCause(Class<? extends Throwable> type)
Starts expecting of exception with root cause of specified type.
|
<A extends AbstractThrowableAssert<A,T>,T extends Throwable> |
expectRootCauseWith(Class<A> assertClass) |
<A extends AbstractThrowableAssert<A,T>,T extends Throwable> |
expectWith(Class<A> assertClass)
Starts expecting exception and return custom throwable assert to specify expectations on exception.
|
protected void |
failBecauseExceptionWasNotThrown()
Throws AssertionError with info that exception was expected but not thrown.
|
S |
handleAssertionErrors()
Starts handling of assertion errors.
|
S |
handleAssumptionViolatedExceptions()
Starts handling of AssumptionViolatedException.
|
protected void |
handleException(Throwable e)
Handles thrown exception.
|
boolean |
isExceptionExpected()
Returns if rule is expecting any exception.
|
protected S |
myself() |
static FluentExpectedException |
none()
Creates and returns new instance of
FluentExpectedException rule. |
protected FluentExpectedException()
FluentExpectedException rule.
Standard constructor for extending.protected FluentExpectedException(ProxiesFactory proxiesFactory)
FluentExpectedException rule.proxiesFactory - public static FluentExpectedException none()
FluentExpectedException rule.public ThrowableAssert expect()
ThrowableAssert to specify more expectationspublic ThrowableAssert expect(Class<? extends Throwable> type)
type - expected type of exceptionThrowableAssert to specify more expectationspublic <A extends AbstractThrowableAssert<A,T>,T extends Throwable> A expectWith(Class<A> assertClass)
AbstractThrowableAssert and returns proxy of it,
to allow specify expectations on thrown exception.A - class of custom throwable assertT - class of throwables supported by custom throwable assertassertClass - class of custom throwable assert, subclass of AbstractThrowableAssertpublic ThrowableAssert expectCause()
ThrowableAssert to specify more expectations on exception's causepublic ThrowableAssert expectCause(Class<? extends Throwable> type)
type - expected type of exception's causeThrowableAssert to specify more expectations on exception's causepublic <A extends AbstractThrowableAssert<A,T>,T extends Throwable> A expectCauseWith(Class<A> assertClass)
public ThrowableAssert expectRootCause()
ThrowableAssert to specify more expectations on exception's root causepublic ThrowableAssert expectRootCause(Class<? extends Throwable> type)
type - expected type of exception's root causeThrowableAssert to specify more expectations on exception's root causepublic <A extends AbstractThrowableAssert<A,T>,T extends Throwable> A expectRootCauseWith(Class<A> assertClass)
protected void addCheck(Check check)
check - callback to assert thrown exceptionpublic boolean isExceptionExpected()
true if any exception is expectedprotected void handleException(Throwable e)
e - thrown exceptionprotected void failBecauseExceptionWasNotThrown()
protected S myself()
public final S handleAssertionErrors()
this to allow chainingpublic final S handleAssumptionViolatedExceptions()
this to allow chainingpublic final Statement apply(Statement base, Description description)
Copyright © 2014. All rights reserved.