|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.fest.assertions.Assert
org.fest.assertions.GenericAssert<ThrowableAssert,Throwable>
org.fest.assertions.ThrowableAssert
public class ThrowableAssert
Assertions for .
Throwable
To create a new instance of this class invoke .
Assertions.assertThat(Throwable)
| Field Summary |
|---|
| Fields inherited from class org.fest.assertions.GenericAssert |
|---|
actual, myself |
| Constructor Summary | |
|---|---|
protected |
ThrowableAssert(Throwable actual)
Creates a new ThrowableAssert. |
| Method Summary | |
|---|---|
ThrowableAssert |
as(Description description)
Sets the description of the actual value, to be used in as message of any
thrown when an assertion fails. |
ThrowableAssert |
as(String description)
Sets the description of the actual value, to be used in as message of any
thrown when an assertion fails. |
ThrowableAssert |
describedAs(Description description)
Alias for , since "as" is a keyword in
Groovy. |
ThrowableAssert |
describedAs(String description)
Alias for , since "as" is a keyword in
Groovy. |
ThrowableAssert |
hasMessage(String message)
Verifies that the message of the actual Throwable is equal to the given one. |
ThrowableAssert |
hasNoCause()
Verifies that the actual Throwable does not have a cause. |
ThrowableAssert |
isExactlyInstanceOf(Class<?> type)
Verifies that the actual Throwable is an instance of the given type. |
ThrowableAssert |
isInstanceOf(Class<? extends Throwable> type)
Verifies that the actual Throwable is an instance of the given type. |
ThrowableAssert |
overridingErrorMessage(String message)
Replaces the default message displayed in case of a failure with the given one. |
| Methods inherited from class org.fest.assertions.GenericAssert |
|---|
doesNotSatisfy, is, isEqualTo, isIn, isIn, isNot, isNotEqualTo, isNotIn, isNotIn, isNotNull, isNotSameAs, isNull, isSameAs, satisfies |
| Methods inherited from class org.fest.assertions.Assert |
|---|
customErrorMessage, description, description, description, equals, fail, fail, failIfCustomMessageIsSet, failIfCustomMessageIsSet, failure, formattedErrorMessage, hashCode, rawDescription, replaceDefaultErrorMessagesWith |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
protected ThrowableAssert(Throwable actual)
ThrowableAssert.
actual - the target to verify.| Method Detail |
|---|
public ThrowableAssert isInstanceOf(Class<? extends Throwable> type)
Throwable is an instance of the given type.
type - the type to check the actual Throwable against.
AssertionError - if the actual Throwable is null.
AssertionError - if the actual Throwable is not an instance of the given type.
NullPointerException - if the given type is null.public ThrowableAssert isExactlyInstanceOf(Class<?> type)
Throwable is an instance of the given type. In order for the assertion to
pass, the type of the actual Throwable has to be exactly the same as the given type.
type - the type to check the actual Throwable against.
AssertionError - if the actual Throwable is null.
AssertionError - if the actual Throwable is not an instance of the given type.
NullPointerException - if the given type is null.public ThrowableAssert hasMessage(String message)
Throwable is equal to the given one.
message - the expected message.
AssertionError - if the actual Throwable is null.
AssertionError - if the message of the actual Throwable is not equal to the given one.public ThrowableAssert hasNoCause()
Throwable does not have a cause.
AssertionError - if the actual Throwable is null.
AssertionError - if the actual Throwable has a cause.public ThrowableAssert as(String description)
AssertionError
thrown when an assertion fails. This method should be called before any assertion method, otherwise any assertion
failure will not show the provided description.
For example:
assertThat(val).as("name").isEqualTo("Frodo");
as in class GenericAssert<ThrowableAssert,Throwable>description - the description of the actual value.
public ThrowableAssert describedAs(String description)
GenericAssert.as(String), since "as" is a keyword in
Groovy. This method should be called before any assertion
method, otherwise any assertion failure will not show the provided description.
For example:
assertThat(val).describedAs("name").isEqualTo("Frodo");
describedAs in class GenericAssert<ThrowableAssert,Throwable>description - the description of the actual value.
public ThrowableAssert as(Description description)
AssertionError
thrown when an assertion fails. This method should be called before any assertion method, otherwise any assertion
failure will not show the provided description.
For example:
assertThat(val).as(new BasicDescription("name")).isEqualTo("Frodo");
as in class GenericAssert<ThrowableAssert,Throwable>description - the description of the actual value.
public ThrowableAssert describedAs(Description description)
GenericAssert.as(Description), since "as" is a keyword in
Groovy. This method should be called before any assertion
method, otherwise any assertion failure will not show the provided description.
For example:
assertThat(val).describedAs(new BasicDescription("name")).isEqualTo("Frodo");
describedAs in class GenericAssert<ThrowableAssert,Throwable>description - the description of the actual value.
public ThrowableAssert overridingErrorMessage(String message)
For example, the following assertion:
assertThat("Hello").isEqualTo("Bye");
will fail with the default message "expected:<'[Bye]'> but was:<'[Hello]'>."
We can replace this message with our own:
assertThat("Hello").overridingErrorMessage("'Hello' should be equal to 'Bye'").isEqualTo("Bye");
in this case, the assertion will fail showing the message "'Hello' should be equal to 'Bye'".
overridingErrorMessage in class GenericAssert<ThrowableAssert,Throwable>message - the given error message, which will replace the default one.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||