org.assertj.core.api
Interface Descriptable<S extends Descriptable<S>>

Type Parameters:
S - the "self" type of this assertion class. Please read "Emulating 'self types' using Java Generics to simplify fluent API implementation" for more details.
All Known Subinterfaces:
Assert<S,A>
All Known Implementing Classes:
AbstractArrayAssert, AbstractAssert, AbstractBigDecimalAssert, AbstractBooleanArrayAssert, AbstractBooleanAssert, AbstractByteArrayAssert, AbstractByteAssert, AbstractCharacterAssert, AbstractCharArrayAssert, AbstractCharSequenceAssert, AbstractClassAssert, AbstractComparableAssert, AbstractDateAssert, AbstractDoubleArrayAssert, AbstractDoubleAssert, AbstractEnumerableAssert, AbstractFileAssert, AbstractFloatArrayAssert, AbstractFloatAssert, AbstractInputStreamAssert, AbstractIntArrayAssert, AbstractIntegerAssert, AbstractIterableAssert, AbstractListAssert, AbstractLongArrayAssert, AbstractLongAssert, AbstractMapAssert, AbstractObjectArrayAssert, AbstractObjectAssert, AbstractShortArrayAssert, AbstractShortAssert, AbstractThrowableAssert, AbstractUnevenComparableAssert, AllOf, AnyOf, BigDecimalAssert, BooleanArrayAssert, BooleanAssert, ByteArrayAssert, ByteAssert, CharacterAssert, CharArrayAssert, CharSequenceAssert, ClassAssert, Condition, DateAssert, DoesNotHave, DoubleArrayAssert, DoubleAssert, FileAssert, FloatArrayAssert, FloatAssert, GenericComparableAssert, InputStreamAssert, IntArrayAssert, IntegerAssert, IterableAssert, Join, ListAssert, LongArrayAssert, LongAssert, MapAssert, Negative, Not, ObjectArrayAssert, ObjectAssert, ShortArrayAssert, ShortAssert, StringAssert, ThrowableAssert

public interface Descriptable<S extends Descriptable<S>>

An object that has a description.

Author:
Alex Ruiz, Yvonne Wang, Mikhail Mazursky

Method Summary
 S as(Description description)
          Sets the description of this object.
 S as(String description, Object... args)
          Sets the description of this object supporting String.format(String, Object...) syntax.
 S describedAs(Description description)
          Alias for as(String, Object...) since "as" is a keyword in Groovy.
 S describedAs(String description, Object... args)
          Alias for as(String, Object...) since "as" is a keyword in Groovy.
 

Method Detail

as

S as(String description,
     Object... args)
Sets the description of this object supporting String.format(String, Object...) syntax.

Example :

 try {
   // set a bad age to Mr Frodo which is really 33 years old.
   frodo.setAge(50);
   // you can specify a test description with as() method or describedAs(), it supports String format args
   assertThat(frodo.getAge()).as("check %s's age", frodo.getName()).isEqualTo(33);
 } catch (AssertionError e) {
   assertThat(e).hasMessage("[check Frodo's age] expected:<[33]> but was:<[50]>");
 }
 
 

Parameters:
description - the new description to set.
args - optional parameter if description is a format String.
Returns:
this object.
Throws:
NullPointerException - if the description is null.
See Also:
describedAs(String, Object...)

as

S as(Description description)
Sets the description of this object. To remove or clear the description, pass a EmptyTextDescription as argument.

This overloaded version of "describedAs" offers more flexibility than the one taking a String by allowing users to pass their own implementation of a description. For example, a description that creates its value lazily, only when an assertion failure occurs.

Parameters:
description - the new description to set.
Returns:
this object.
Throws:
NullPointerException - if the description is null.
See Also:
describedAs(Description)

describedAs

S describedAs(String description,
              Object... args)
Alias for as(String, Object...) since "as" is a keyword in Groovy.

Parameters:
description - the new description to set.
Returns:
this object.
Throws:
NullPointerException - if the description is null.

describedAs

S describedAs(Description description)
Alias for as(String, Object...) since "as" is a keyword in Groovy. To remove or clear the description, pass a EmptyTextDescription as argument.

This overloaded version of "describedAs" offers more flexibility than the one taking a String by allowing users to pass their own implementation of a description. For example, a description that creates its value lazily, only when an assertion failure occurs.

Parameters:
description - the new description to set.
Returns:
this object.
Throws:
NullPointerException - if the description is null.


Copyright © 2013–2015 AssertJ. All rights reserved.