com.googlecode.catchexception.apis.BDDCatchException()
@Deprecated public class CatchExceptionAssertJ extends BDDCatchException
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 IndexOutOfBoundsException
then(caughtException())
.isInstanceOf(IndexOutOfBoundsException.class)
.hasMessage("Index: 1, Size: 0")
.hasNoCause();
// then we expect an IndexOutOfBoundsException (alternatively)
thenThrown(IndexOutOfBoundsException.class);
The Method then(Exception)
uses AssertJ
assertions. You can use them directly if you like:
// import static org.assertj.core.api.Assertions.assertThat;
// then we expect an IndexOutOfBoundsException
assertThat(caughtException())
.isInstanceOf(IndexOutOfBoundsException.class)
.hasMessage("Index: 1, Size: 0")
.hasMessageStartingWith("Index: 1")
.hasMessageEndingWith("Size: 0")
.hasMessageContaining("Size")
.hasNoCause();
BDDCatchException
Constructor and Description |
---|
CatchExceptionAssertJ()
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
static org.assertj.core.api.AbstractThrowableAssert<?,? extends Throwable> |
then(Exception actualException)
Deprecated.
As of release 1.3.0, replaced by
org.assertj.core.api.BDDAssertions#then(Throwable) |
thenThrown, when
public CatchExceptionAssertJ()
public static org.assertj.core.api.AbstractThrowableAssert<?,? extends Throwable> then(Exception actualException)
org.assertj.core.api.BDDAssertions#then(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 IndexOutOfBoundsException
then(caughtException())
.isInstanceOf(IndexOutOfBoundsException.class)
.hasMessage("Index: 1, Size: 0")
.hasMessageStartingWith("Index: 1")
.hasMessageEndingWith("Size: 0")
.hasMessageContaining("Size")
.hasNoCause();
actualException
- the value to be the target of the assertions methods.Assertions.assertThat(Throwable)
Copyright © 2014. All rights reserved.