com.googlecode.catchexception.apis.BDDCatchException()
@Deprecated public class CatchExceptionBdd 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 FEST Fluent Assertions
2.x. You can use them directly if you like:
// import static org.fest.assertions.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 |
---|
CatchExceptionBdd()
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
static org.fest.assertions.api.ThrowableAssert |
then(Exception actualException)
Deprecated.
Enables FEST Fluent
Assertions 2.x about the caught exception.
|
thenThrown, when
public CatchExceptionBdd()
public static org.fest.assertions.api.ThrowableAssert then(Exception actualException)
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.