public class BDDAssertions extends Assertions
The difference with Assertions class is that entry point methods are named then
instead of
assertThat
.
For example:
@Test
public void bdd_assertions_examples() {
//given
List<BasketBallPlayer> bulls = new ArrayList<BasketBallPlayer>();
//when
bulls.add(rose);
bulls.add(noah);
then(bulls).contains(rose, noah).doesNotContain(james);
}
Modifier | Constructor and Description |
---|---|
protected |
BDDAssertions()
Creates a new
BDDAssertions . |
Modifier and Type | Method and Description |
---|---|
static AbstractBigDecimalAssert<?> |
then(BigDecimal actual)
Creates a new instance of
. |
static AbstractBooleanAssert<?> |
then(boolean actual)
Creates a new instance of
. |
static AbstractBooleanAssert<?> |
then(Boolean actual)
Creates a new instance of
. |
static AbstractBooleanArrayAssert<?> |
then(boolean[] actual)
Creates a new instance of
. |
static AbstractByteAssert<?> |
then(byte actual)
Creates a new instance of
. |
static AbstractByteAssert<?> |
then(Byte actual)
Creates a new instance of
. |
static AbstractByteArrayAssert<?> |
then(byte[] actual)
Creates a new instance of
. |
static AbstractCharacterAssert<?> |
then(char actual)
Creates a new instance of
. |
static AbstractCharArrayAssert<?> |
then(char[] actual)
Creates a new instance of
. |
static AbstractCharacterAssert<?> |
then(Character actual)
Creates a new instance of
. |
static AbstractCharSequenceAssert<?,? extends CharSequence> |
then(CharSequence actual)
Creates a new instance of
. |
static AbstractClassAssert<?> |
then(Class<?> actual)
Creates a new instance of
|
static AbstractDateAssert<?> |
then(Date actual)
Creates a new instance of
. |
static AbstractDoubleAssert<?> |
then(double actual)
Creates a new instance of
. |
static AbstractDoubleAssert<?> |
then(Double actual)
Creates a new instance of
. |
static AbstractDoubleArrayAssert<?> |
then(double[] actual)
Creates a new instance of
. |
static AbstractFileAssert<?> |
then(File actual)
Creates a new instance of
. |
static AbstractFloatAssert<?> |
then(float actual)
Creates a new instance of
. |
static AbstractFloatAssert<?> |
then(Float actual)
Creates a new instance of
. |
static AbstractFloatArrayAssert<?> |
then(float[] actual)
Creates a new instance of
. |
static AbstractInputStreamAssert<?,? extends InputStream> |
then(InputStream actual)
Creates a new instance of
. |
static AbstractIntegerAssert<?> |
then(int actual)
Creates a new instance of
. |
static AbstractIntArrayAssert<?> |
then(int[] actual)
Creates a new instance of
. |
static AbstractIntegerAssert<?> |
then(Integer actual)
Creates a new instance of
. |
static <T> AbstractIterableAssert<?,? extends Iterable<? extends T>,T> |
then(Iterable<? extends T> actual)
Creates a new instance of
. |
static <T> AbstractIterableAssert<?,? extends Iterable<? extends T>,T> |
then(Iterator<? extends T> actual)
Creates a new instance of
. |
static <T> AbstractListAssert<?,? extends List<? extends T>,T> |
then(List<? extends T> actual)
Creates a new instance of
. |
static AbstractLongAssert<?> |
then(long actual)
Creates a new instance of
. |
static AbstractLongAssert<?> |
then(Long actual)
Creates a new instance of
. |
static AbstractLongArrayAssert<?> |
then(long[] actual)
Creates a new instance of
. |
static <K,V> AbstractMapAssert<?,? extends Map<K,V>,K,V> |
then(Map<K,V> actual)
Creates a new instance of
. |
static AbstractShortAssert<?> |
then(short actual)
Creates a new instance of
. |
static AbstractShortAssert<?> |
then(Short actual)
Creates a new instance of
. |
static AbstractShortArrayAssert<?> |
then(short[] actual)
Creates a new instance of
. |
static AbstractCharSequenceAssert<?,String> |
then(String actual)
Creates a new instance of
. |
static <T> AbstractObjectAssert<?,T> |
then(T actual)
Creates a new instance of
. |
static <T extends Comparable<? super T>> |
then(T actual)
Creates a new instance of
with
standard comparison semantics. |
static <T> AbstractObjectArrayAssert<?,T> |
then(T[] actual)
Creates a new instance of
. |
static AbstractThrowableAssert<?,? extends Throwable> |
then(Throwable actual)
Creates a new instance of
. |
static AbstractUriAssert<?> |
then(URI actual)
Creates a new instance of
. |
static AbstractUrlAssert<?> |
then(URL actual)
Creates a new instance of
. |
static AbstractThrowableAssert<?,? extends Throwable> |
thenThrownBy(ThrowableAssert.ThrowingCallable shouldRaiseThrowable)
Allows to capture and then assert on a
Throwable more easily when used with Java 8 lambdas. |
allOf, allOf, anyOf, anyOf, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThatThrownBy, atIndex, catchThrowable, contentOf, contentOf, contentOf, contentOf, contentOf, contentOf, doesNotHave, entry, extractProperty, extractProperty, fail, fail, failBecauseExceptionWasNotThrown, filter, filter, in, linesOf, linesOf, linesOf, linesOf, linesOf, linesOf, not, not, notIn, offset, offset, registerCustomDateFormat, registerCustomDateFormat, setAllowComparingPrivateFields, setAllowExtractingPrivateFields, setLenientDateParsing, setMaxLengthForSingleLineDescription, setRemoveAssertJRelatedElementsFromStackTrace, shouldHaveThrown, tuple, useDefaultDateFormatsOnly, within, within, within, within, within, within, within, withinPercentage, withinPercentage, withinPercentage
protected BDDAssertions()
BDDAssertions
.public static AbstractBigDecimalAssert<?> then(BigDecimal actual)
BigDecimalAssert
.actual
- the actual value.public static AbstractBooleanAssert<?> then(boolean actual)
BooleanAssert
.actual
- the actual value.public static AbstractBooleanAssert<?> then(Boolean actual)
BooleanAssert
.actual
- the actual value.public static AbstractBooleanArrayAssert<?> then(boolean[] actual)
BooleanArrayAssert
.actual
- the actual value.public static AbstractByteAssert<?> then(byte actual)
ByteAssert
.actual
- the actual value.public static AbstractByteAssert<?> then(Byte actual)
ByteAssert
.actual
- the actual value.public static AbstractByteArrayAssert<?> then(byte[] actual)
ByteArrayAssert
.actual
- the actual value.public static AbstractCharacterAssert<?> then(char actual)
CharacterAssert
.actual
- the actual value.public static AbstractCharArrayAssert<?> then(char[] actual)
CharArrayAssert
.actual
- the actual value.public static AbstractCharacterAssert<?> then(Character actual)
CharacterAssert
.actual
- the actual value.public static AbstractClassAssert<?> then(Class<?> actual)
ClassAssert
actual
- the actual value.public static <T extends Comparable<? super T>> AbstractComparableAssert<?,T> then(T actual)
GenericComparableAssert
with
standard comparison semantics.actual
- the actual value.public static <T> AbstractIterableAssert<?,? extends Iterable<? extends T>,T> then(Iterable<? extends T> actual)
IterableAssert
.actual
- the actual value.public static <T> AbstractIterableAssert<?,? extends Iterable<? extends T>,T> then(Iterator<? extends T> actual)
actual
- the actual value.public static AbstractDoubleAssert<?> then(double actual)
DoubleAssert
.actual
- the actual value.public static AbstractDoubleAssert<?> then(Double actual)
DoubleAssert
.actual
- the actual value.public static AbstractDoubleArrayAssert<?> then(double[] actual)
DoubleArrayAssert
.actual
- the actual value.public static AbstractFileAssert<?> then(File actual)
FileAssert
.actual
- the actual value.public static AbstractInputStreamAssert<?,? extends InputStream> then(InputStream actual)
InputStreamAssert
.actual
- the actual value.public static AbstractFloatAssert<?> then(float actual)
FloatAssert
.actual
- the actual value.public static AbstractFloatAssert<?> then(Float actual)
FloatAssert
.actual
- the actual value.public static AbstractFloatArrayAssert<?> then(float[] actual)
FloatArrayAssert
.actual
- the actual value.public static AbstractIntegerAssert<?> then(int actual)
IntegerAssert
.actual
- the actual value.public static AbstractIntArrayAssert<?> then(int[] actual)
IntArrayAssert
.actual
- the actual value.public static AbstractIntegerAssert<?> then(Integer actual)
IntegerAssert
.actual
- the actual value.public static <T> AbstractListAssert<?,? extends List<? extends T>,T> then(List<? extends T> actual)
ListAssert
.actual
- the actual value.public static AbstractLongAssert<?> then(long actual)
LongAssert
.actual
- the actual value.public static AbstractLongAssert<?> then(Long actual)
LongAssert
.actual
- the actual value.public static AbstractLongArrayAssert<?> then(long[] actual)
LongArrayAssert
.actual
- the actual value.public static <T> AbstractObjectAssert<?,T> then(T actual)
ObjectAssert
.actual
- the actual value.public static <T> AbstractObjectArrayAssert<?,T> then(T[] actual)
ObjectArrayAssert
.actual
- the actual value.public static <K,V> AbstractMapAssert<?,? extends Map<K,V>,K,V> then(Map<K,V> actual)
MapAssert
.actual
- the actual value.public static AbstractShortAssert<?> then(short actual)
ShortAssert
.actual
- the actual value.public static AbstractShortAssert<?> then(Short actual)
ShortAssert
.actual
- the actual value.public static AbstractShortArrayAssert<?> then(short[] actual)
ShortArrayAssert
.actual
- the actual value.public static AbstractCharSequenceAssert<?,? extends CharSequence> then(CharSequence actual)
CharSequenceAssert
.actual
- the actual value.public static AbstractCharSequenceAssert<?,String> then(String actual)
StringAssert
.actual
- the actual value.public static AbstractDateAssert<?> then(Date actual)
DateAssert
.actual
- the actual value.public static AbstractThrowableAssert<?,? extends Throwable> then(Throwable actual)
ThrowableAssert
.actual
- the actual value.public static AbstractThrowableAssert<?,? extends Throwable> thenThrownBy(ThrowableAssert.ThrowingCallable shouldRaiseThrowable)
Throwable
more easily when used with Java 8 lambdas.
Java 8 example :
@Test
public void testException() {
thenThrownBy(() -> { throw new Exception("boom!") }).isInstanceOf(Exception.class)
.hasMessageContaining("boom");
}
Java 7 example :
thenThrownBy(new ThrowingCallable() {
@Override
public Void call() throws Exception {
throw new Exception("boom!");
}
}).isInstanceOf(Exception.class)
.hasMessageContaining("boom");
shouldRaiseThrowable
- The ThrowableAssert.ThrowingCallable
or lambda with the code that should raise the throwable.null
if none was raised by the callable.public static AbstractUriAssert<?> then(URI actual)
UriAssert
.actual
- the actual value.public static AbstractUrlAssert<?> then(URL actual)
UrlAssert
.actual
- the actual value.Copyright © 2013-2015 AssertJ. All Rights Reserved.