com.googlecode.catchexception.throwable.apis.BDDCatchThrowable()@Deprecated public class CatchThrowableAssertJ extends BDDCatchThrowable
EXAMPLE: // given an empty list
List myList = new ArrayList();
// when we try to get the first element of the list
when(myList).get(1);
// then we expect an IndexOutOfBoundsThrowable
then(caughtThrowable())
.isInstanceOf(IndexOutOfBoundsThrowable.class)
.hasMessage("Index: 1, Size: 0")
.hasNoCause();
// then we expect an IndexOutOfBoundsThrowable (alternatively)
thenThrown(IndexOutOfBoundsThrowable.class);
The Method then(Throwable) uses AssertJ
assertions. You can use them directly if you like:
// import static org.assertj.core.api.Assertions.assertThat;
// then we expect an IndexOutOfBoundsThrowable
assertThat(caughtThrowable())
.isInstanceOf(IndexOutOfBoundsThrowable.class)
.hasMessage("Index: 1, Size: 0")
.hasMessageStartingWith("Index: 1")
.hasMessageEndingWith("Size: 0")
.hasMessageContaining("Size")
.hasNoCause();
Assertions.assertThat(Throwable)| Constructor and Description |
|---|
CatchThrowableAssertJ()
Deprecated.
|
| Modifier and Type | Method and Description |
|---|---|
static org.assertj.core.api.AbstractThrowableAssert<?,? extends Throwable> |
then(Throwable actualThrowable)
Deprecated.
As of release 1.3.0, replaced by
org.assertj.core.api.BDDAssertions#then(java.lang.Throwable |
thenThrown, whenpublic CatchThrowableAssertJ()
public static org.assertj.core.api.AbstractThrowableAssert<?,? extends Throwable> then(Throwable actualThrowable)
org.assertj.core.api.BDDAssertions#then(java.lang.Throwable
EXAMPLE: // given an empty list
List myList = new ArrayList();
// when we try to get first element of the list
when(myList).get(1);
// then we expect an IndexOutOfBoundsThrowable
then(caughtThrowable())
.isInstanceOf(IndexOutOfBoundsThrowable.class)
.hasMessage("Index: 1, Size: 0")
.hasMessageStartingWith("Index: 1")
.hasMessageEndingWith("Size: 0")
.hasMessageContaining("Size")
.hasNoCause();
actualThrowable - the value to be the target of the assertions methods.org.assertj.core.api.BDDAssertions#then(Throwable)Copyright © 2014. All rights reserved.