|
||||||||||
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<String>
org.fest.assertions.StringAssert
public class StringAssert
Understands assertion methods for String
s. To create a new instance of this class use the
method
.
Assertions.assertThat(String)
Field Summary |
---|
Fields inherited from class org.fest.assertions.GenericAssert |
---|
actual |
Constructor Summary | |
---|---|
protected |
StringAssert(String actual)
Creates a new StringAssert . |
Method Summary | |
---|---|
protected int |
actualGroupSize()
Returns the number of elements in the actual String . |
StringAssert |
as(Description description)
Sets the description of the actual value, to be used in as message of any
thrown when an assertion fails. |
StringAssert |
as(String description)
Sets the description of the actual value, to be used in as message of any
thrown when an assertion fails. |
StringAssert |
contains(String expected)
Verifies that the actual String contains the given one. |
StringAssert |
containsIgnoringCase(String text)
Verifies that the actual String contains the given text regardless of the case. |
StringAssert |
describedAs(Description description)
Alias for , since "as" is a keyword in
Groovy. |
StringAssert |
describedAs(String description)
Alias for , since "as" is a keyword in
Groovy. |
StringAssert |
doesNotContain(String text)
Verifies that the actual String does not contain the given text. |
StringAssert |
doesNotMatch(String regex)
Verifies that the actual String does not match the given one. |
StringAssert |
doesNotSatisfy(Condition<String> condition)
Verifies that the actual String does not satisfy the given condition. |
StringAssert |
endsWith(String expected)
Verifies that the actual String ends with the given one. |
StringAssert |
excludes(String s)
Verifies that the actual String does not contains the given one. |
StringAssert |
hasSize(int expected)
Verifies that the number of characters in the actual String is equal to the given one. |
StringAssert |
is(Condition<String> condition)
Alias for . |
StringAssert |
isEqualTo(String expected)
Verifies that the actual String is equal to the given one. |
StringAssert |
isEqualToIgnoringCase(String expected)
Verifies that the actual String is equal to the given one ignoring case. |
StringAssert |
isNot(Condition<String> condition)
Alias for . |
StringAssert |
isNotEmpty()
Verifies that the actual String contains at least on character. |
StringAssert |
isNotEqualTo(String other)
Verifies that the actual String is not equal to the given one. |
StringAssert |
isNotNull()
Verifies that the actual String is not null . |
StringAssert |
isNotSameAs(String other)
Verifies that the actual String is not the same as the given one. |
StringAssert |
isSameAs(String expected)
Verifies that the actual String is the same as the given one. |
StringAssert |
matches(String regex)
Verifies that the actual String matches the given one. |
StringAssert |
overridingErrorMessage(String message)
Replaces the default message displayed in case of a failure with the given one. |
StringAssert |
satisfies(Condition<String> condition)
Verifies that the actual String satisfies the given condition. |
StringAssert |
startsWith(String expected)
Verifies that the actual String starts with the given one. |
Methods inherited from class org.fest.assertions.GroupAssert |
---|
assertHasSize, assertIsNotEmpty, isEmpty, isNullOrEmpty |
Methods inherited from class org.fest.assertions.GenericAssert |
---|
assertDoesNotSatisfy, assertEqualTo, assertIs, assertIsNot, assertNotEqualTo, assertNotNull, assertNotSameAs, assertSameAs, assertSatisfies, isNull |
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 StringAssert(String actual)
StringAssert
.
actual
- the target to verify.Method Detail |
---|
public StringAssert 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 GroupAssert<String>
description
- the description of the actual value.
public StringAssert 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 GroupAssert<String>
description
- the description of the actual value.
public StringAssert 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 GroupAssert<String>
description
- the description of the actual value.
public StringAssert 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 GroupAssert<String>
description
- the description of the actual value.
public StringAssert satisfies(Condition<String> condition)
String
satisfies the given condition.
satisfies
in class GenericAssert<String>
condition
- the given condition.
NullPointerException
- if the given condition is null
.
AssertionError
- if the actual String
does not satisfy the given condition.is(Condition)
public StringAssert doesNotSatisfy(Condition<String> condition)
String
does not satisfy the given condition.
doesNotSatisfy
in class GenericAssert<String>
condition
- the given condition.
NullPointerException
- if the given condition is null
.
AssertionError
- if the actual String
satisfies the given condition.isNot(Condition)
public StringAssert is(Condition<String> condition)
satisfies(Condition)
.
is
in class GenericAssert<String>
condition
- the given condition.
NullPointerException
- if the given condition is null
.
AssertionError
- if the actual String
does not satisfy the given condition.public StringAssert isNot(Condition<String> condition)
doesNotSatisfy(Condition)
.
isNot
in class GenericAssert<String>
condition
- the given condition.
NullPointerException
- if the given condition is null
.
AssertionError
- if the actual String
satisfies the given condition.public StringAssert isNotEmpty()
String
contains at least on character.
isNotEmpty
in class GroupAssert<String>
AssertionError
- if the actual String
is null
or empty.public StringAssert isEqualTo(String expected)
String
is equal to the given one.
isEqualTo
in class GenericAssert<String>
expected
- the given String
to compare the actual String
to.
AssertionError
- if the actual String
is not equal to the given one.public StringAssert isEqualToIgnoringCase(String expected)
String
is equal to the given one ignoring case.
expected
- the given String
to compare the actual String
to.
AssertionError
- if the actual String
is null
.
AssertionError
- if the actual String
is not equal to the given one ignoring case.public StringAssert isNotEqualTo(String other)
String
is not equal to the given one.
isNotEqualTo
in class GenericAssert<String>
other
- the given String
to compare the actual String
to.
AssertionError
- if the actual String
is equal to the given one.public StringAssert isNotNull()
String
is not null
.
isNotNull
in class GenericAssert<String>
AssertionError
- if the actual String
is null
.public StringAssert isNotSameAs(String other)
String
is not the same as the given one.
isNotSameAs
in class GenericAssert<String>
other
- the given String
to compare the actual String
to.
AssertionError
- if the actual String
is the same as the given one.public StringAssert isSameAs(String expected)
String
is the same as the given one.
isSameAs
in class GenericAssert<String>
expected
- the given String
to compare the actual String
to.
AssertionError
- if the actual String
is not the same as the given one.public StringAssert hasSize(int expected)
String
is equal to the given one.
hasSize
in class GroupAssert<String>
expected
- the expected number of characters in the actual String
.
AssertionError
- if the number of characters of the actual String
is not equal to the given one.protected int actualGroupSize()
String
.
actualGroupSize
in class GroupAssert<String>
String
.public StringAssert contains(String expected)
String
contains the given one.
expected
- the given String
expected to be contained in the actual one.
AssertionError
- if the actual String
is null
.
AssertionError
- if the actual String
does not contain the given one.public StringAssert endsWith(String expected)
String
ends with the given one.
expected
- the given String
expected to be at the end of the actual one.
AssertionError
- if the actual String
is null
.
AssertionError
- if the actual String
does not end with the given one.public StringAssert startsWith(String expected)
String
starts with the given one.
expected
- the given String
expected to be at the beginning of the actual one.
AssertionError
- if the actual String
is null
.
AssertionError
- if the actual String
does not start with the given one.public StringAssert excludes(String s)
String
does not contains the given one.
s
- the given String
expected not to be contained in the actual one.
AssertionError
- if the actual String
is null
.
AssertionError
- if the actual String
does contain the given one.public StringAssert matches(String regex)
String
matches the given one.
regex
- the given regular expression expected to be matched by the actual one.
AssertionError
- if the actual String
is null
.
AssertionError
- if the actual String
does not match the given regular expression.public StringAssert doesNotMatch(String regex)
String
does not match the given one.
regex
- the given regular expression expected not to be matched by the actual one.
AssertionError
- if the actual String
is null
.
AssertionError
- if the actual String
matches the given regular expression.public StringAssert 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 GroupAssert<String>
message
- the given error message, which will replace the default one.
public StringAssert containsIgnoringCase(String text)
String
contains the given text regardless of the case.
text
- the given text.
AssertionError
- if the actual String
is null
.
AssertionError
- if the actual String
does not contain the given text.
NullPointerException
- if the given String
is null
.public StringAssert doesNotContain(String text)
String
does not contain the given text.
text
- the given text.
AssertionError
- if the actual String
is null
.
AssertionError
- if the actual String
contains the given text.
NullPointerException
- if the given String
is null
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |