S
- the "self" type of this assertion class. Please read "Emulating 'self types' using Java Generics to simplify fluent API implementation"
for more details.public interface Descriptable<S extends Descriptable<S>>
Modifier and Type | Method and Description |
---|---|
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
since "as" is a keyword in Groovy. |
S |
describedAs(String description,
Object... args)
Alias for
since "as" is a keyword in Groovy. |
S as(String description, Object... args)
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]>"); }
description
- the new description to set.args
- optional parameter if description is a format String.this
object.NullPointerException
- if the description is null
.describedAs(String, Object...)
S as(Description description)
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.
description
- the new description to set.this
object.NullPointerException
- if the description is null
.describedAs(Description)
S describedAs(String description, Object... args)
as(String, Object...)
since "as" is a keyword in Groovy.description
- the new description to set.this
object.NullPointerException
- if the description is null
.S describedAs(Description description)
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.
description
- the new description to set.this
object.NullPointerException
- if the description is null
.Copyright © 2013 AssertJ. All Rights Reserved.