Interface Descriptable<SELF extends Descriptable<SELF>>
- Type Parameters:
SELF
- 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<SELF,
ACTUAL>
- All Known Implementing Classes:
AbstractArrayAssert
,AbstractAssert
,AbstractAtomicFieldUpdaterAssert
,AbstractAtomicReferenceAssert
,AbstractBigDecimalAssert
,AbstractBigIntegerAssert
,AbstractBooleanArrayAssert
,AbstractBooleanAssert
,AbstractByteArrayAssert
,AbstractByteAssert
,AbstractCharacterAssert
,AbstractCharArrayAssert
,AbstractCharSequenceAssert
,AbstractClassAssert
,AbstractComparableAssert
,AbstractCompletableFutureAssert
,AbstractDateAssert
,AbstractDoubleArrayAssert
,AbstractDoubleAssert
,AbstractEnumerableAssert
,AbstractFileAssert
,AbstractFloatArrayAssert
,AbstractFloatAssert
,AbstractFutureAssert
,AbstractInputStreamAssert
,AbstractInstantAssert
,AbstractIntArrayAssert
,AbstractIntegerAssert
,AbstractIterableAssert
,AbstractIterableSizeAssert
,AbstractListAssert
,AbstractLocalDateAssert
,AbstractLocalDateTimeAssert
,AbstractLocalTimeAssert
,AbstractLongArrayAssert
,AbstractLongAssert
,AbstractMapAssert
,AbstractMapSizeAssert
,AbstractObjectArrayAssert
,AbstractObjectAssert
,AbstractOffsetDateTimeAssert
,AbstractOffsetTimeAssert
,AbstractOptionalAssert
,AbstractOptionalDoubleAssert
,AbstractOptionalIntAssert
,AbstractOptionalLongAssert
,AbstractPathAssert
,AbstractPredicateAssert
,AbstractPredicateLikeAssert
,AbstractShortArrayAssert
,AbstractShortAssert
,AbstractTemporalAssert
,AbstractThrowableAssert
,AbstractUriAssert
,AbstractUrlAssert
,AbstractZonedDateTimeAssert
,AllOf
,AnyOf
,AtomicBooleanAssert
,AtomicIntegerArrayAssert
,AtomicIntegerAssert
,AtomicIntegerFieldUpdaterAssert
,AtomicLongArrayAssert
,AtomicLongAssert
,AtomicLongFieldUpdaterAssert
,AtomicMarkableReferenceAssert
,AtomicReferenceArrayAssert
,AtomicReferenceAssert
,AtomicReferenceFieldUpdaterAssert
,AtomicStampedReferenceAssert
,BigDecimalAssert
,BigIntegerAssert
,BooleanArrayAssert
,BooleanAssert
,ByteArrayAssert
,ByteAssert
,CharacterAssert
,CharArrayAssert
,CharSequenceAssert
,ClassAssert
,ClassBasedNavigableIterableAssert
,ClassBasedNavigableListAssert
,CompletableFutureAssert
,Condition
,DateAssert
,DoesNotHave
,DoubleArrayAssert
,DoubleAssert
,DoublePredicateAssert
,FactoryBasedNavigableIterableAssert
,FactoryBasedNavigableListAssert
,FileAssert
,FloatArrayAssert
,FloatAssert
,FutureAssert
,GenericComparableAssert
,InputStreamAssert
,InstantAssert
,IntArrayAssert
,IntegerAssert
,IntPredicateAssert
,IterableAssert
,IterableSizeAssert
,Join
,ListAssert
,LocalDateAssert
,LocalDateTimeAssert
,LocalTimeAssert
,LongArrayAssert
,LongAssert
,LongPredicateAssert
,MapAssert
,MapSizeAssert
,Negative
,Not
,ObjectArrayAssert
,ObjectAssert
,OffsetDateTimeAssert
,OffsetTimeAssert
,OptionalAssert
,OptionalDoubleAssert
,OptionalIntAssert
,OptionalLongAssert
,PathAssert
,PredicateAssert
,ShortArrayAssert
,ShortAssert
,SoftAssertionClassAssert
,SoftAssertionIterableAssert
,SoftAssertionListAssert
,SoftAssertionMapAssert
,SoftAssertionPredicateAssert
,StringAssert
,ThrowableAssert
,ThrowableAssertAlternative
,UriAssert
,UrlAssert
,ZonedDateTimeAssert
-
Method Summary
Modifier and TypeMethodDescriptionSets the description of the assertion that is going to be called after.as
(Description description) Sets the description of the assertion that is going to be called after.describedAs
(String description, Object... args) Sets the description of the assertion that is going to be called after.describedAs
(Description description) Sets the description of the assertion that is going to be called after.
-
Method Details
-
as
Sets the description of the assertion that is going to be called after.You must set it before calling the assertion otherwise it is ignored as the failing assertion breaks the chained call by throwing an AssertionError.
The description follows
String.format(String, Object...)
syntax.Example :
try { // set a bad age to Mr Frodo which is really 33 years old. frodo.setAge(50); // specify a test description (call as() before the assertion !), it supports String format syntax. 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 isnull
.- See Also:
-
as
Sets the description of the assertion that is going to be called after.You must set it before calling the assertion otherwise it is ignored as the failing assertion breaks the chained call by throwing an AssertionError.
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 isnull
.- See Also:
-
describedAs
Sets the description of the assertion that is going to be called after.You must set it before calling the assertion otherwise it is ignored as the failing assertion breaks the chained call by throwing an AssertionError.
Alias for
since "as" is a keyword in Groovy.as(String, Object...)
- Parameters:
description
- the new description to set.- Returns:
this
object.- Throws:
NullPointerException
- if the description isnull
.
-
describedAs
Sets the description of the assertion that is going to be called after.You must set it before calling the assertion otherwise it is ignored as the failing assertion breaks the chained call by throwing an AssertionError.
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 isnull
.
-