|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.fest.assertions.Assert
org.fest.assertions.GenericAssert<T>
org.fest.assertions.GroupAssert<T>
T - the type of object implementations of this template can verify.public abstract class GroupAssert<T>
Understands a template for assertion methods related to classes representing groups of values.
| Field Summary |
|---|
| Fields inherited from class org.fest.assertions.GenericAssert |
|---|
actual |
| Constructor Summary | |
|---|---|
protected |
GroupAssert(T actual)
Creates a new . |
| Method Summary | |
|---|---|
protected abstract int |
actualGroupSize()
Returns the size of the actual group of values (array, collection, etc.) |
protected abstract GroupAssert<T> |
as(Description description)
Sets the description of the actual value, to be used in as message of any
thrown when an assertion fails. |
protected abstract GroupAssert<T> |
as(String description)
Sets the description of the actual value, to be used in as message of any
thrown when an assertion fails. |
protected void |
assertHasSize(int expected)
Verifies that the number of elements in the actual group of values is equal to the given one. |
protected void |
assertIsNotEmpty()
Verifies that the actual group of values contains at least one element. |
protected abstract GroupAssert<T> |
describedAs(Description description)
Alias for , since "as" is a keyword in
Groovy. |
protected abstract GroupAssert<T> |
describedAs(String description)
Alias for , since "as" is a keyword in
Groovy. |
protected abstract GroupAssert<T> |
hasSize(int expected)
Verifies that the number of values in the actual group is equal to the given one. |
void |
isEmpty()
Verifies that the actual group of values is empty. |
protected abstract GroupAssert<T> |
isNotEmpty()
Verifies that the actual group contains at least on value. |
void |
isNullOrEmpty()
Verifies that the actual group of values is null or empty. |
protected abstract GroupAssert<T> |
overridingErrorMessage(String message)
Replaces the default message displayed in case of a failure with the given one. |
| Methods inherited from class org.fest.assertions.GenericAssert |
|---|
assertDoesNotSatisfy, assertEqualTo, assertIs, assertIsNot, assertNotEqualTo, assertNotNull, assertNotSameAs, assertSameAs, assertSatisfies, doesNotSatisfy, is, isEqualTo, isNot, isNotEqualTo, isNotNull, isNotSameAs, isNull, isSameAs, satisfies |
| Methods inherited from class org.fest.assertions.Assert |
|---|
customErrorMessage, description, description, description, equals, fail, fail, failIfCustomMessageIsSet, failIfCustomMessageIsSet, failure, formattedErrorMessage, hashCode, rawDescription, replaceDefaultErrorMessagesWith |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
protected GroupAssert(T actual)
GroupAssert.
actual - the target to verify.| Method Detail |
|---|
public void isNullOrEmpty()
null or empty.
AssertionError - if the actual group of values is not null or not empty.public void isEmpty()
AssertionError - if the actual group of values is null or not empty.protected abstract GroupAssert<T> isNotEmpty()
AssertionError - if the actual group is null or empty.protected final void assertIsNotEmpty()
AssertionError - if the actual group of values is null.
AssertionError - if the actual group of values is empty.protected abstract GroupAssert<T> hasSize(int expected)
expected - the expected number of values in the actual group.
AssertionError - if the number of values of the actual group is not equal to the given one.protected final void assertHasSize(int expected)
expected - the expected number of elements in the actual group of values.
AssertionError - if the actual group of values is null.
AssertionError - if the number of elements of the actual group of values is not equal to the given one.protected abstract int actualGroupSize()
protected abstract GroupAssert<T> as(String description)
AssertionError
thrown when an assertion fails. This method should be called before any assertion method, otherwise any assertion
failure will not show the provided description.
For example:
assertThat(val).as("name").isEqualTo("Frodo");
as in class GenericAssert<T>description - the description of the actual value.
protected abstract GroupAssert<T> describedAs(String description)
GenericAssert.as(String), since "as" is a keyword in
Groovy. This method should be called before any assertion
method, otherwise any assertion failure will not show the provided description.
For example:
assertThat(val).describedAs("name").isEqualTo("Frodo");
describedAs in class GenericAssert<T>description - the description of the actual value.
protected abstract GroupAssert<T> as(Description description)
AssertionError
thrown when an assertion fails. This method should be called before any assertion method, otherwise any assertion
failure will not show the provided description.
For example:
assertThat(val).as(new BasicDescription("name")).isEqualTo("Frodo");
as in class GenericAssert<T>description - the description of the actual value.
protected abstract GroupAssert<T> describedAs(Description description)
GenericAssert.as(Description), since "as" is a keyword in
Groovy. This method should be called before any assertion
method, otherwise any assertion failure will not show the provided description.
For example:
assertThat(val).describedAs(new BasicDescription("name")).isEqualTo("Frodo");
describedAs in class GenericAssert<T>description - the description of the actual value.
protected abstract GroupAssert<T> overridingErrorMessage(String message)
For example, the following assertion:
assertThat("Hello").isEqualTo("Bye");
will fail with the default message "expected:<'[Bye]'> but was:<'[Hello]'>."
We can replace this message with our own:
assertThat("Hello").overridingErrorMessage("'Hello' should be equal to 'Bye'").isEqualTo("Bye");
in this case, the assertion will fail showing the message "'Hello' should be equal to 'Bye'".
overridingErrorMessage in class GenericAssert<T>message - the given error message, which will replace the default one.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||