Matcher<T>
, SelfDescribing
public class HasToString<T> extends FeatureMatcher<T,java.lang.String>
Constructor | Description |
---|---|
HasToString(Matcher<? super java.lang.String> toStringMatcher) |
Modifier and Type | Method | Description |
---|---|---|
protected java.lang.String |
featureValueOf(T actual) |
Implement this to extract the interesting feature.
|
static <T> Matcher<T> |
hasToString(java.lang.String expectedToString) |
Creates a matcher that matches any examined object whose
toString method
returns a value equalTo the specified string. |
static <T> Matcher<T> |
hasToString(Matcher<? super java.lang.String> toStringMatcher) |
Creates a matcher that matches any examined object whose
toString method
returns a value that satisfies the specified matcher. |
_dont_implement_Matcher___instead_extend_BaseMatcher_, toString
describeTo, matchesSafely
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
describeMismatch, matches
public HasToString(Matcher<? super java.lang.String> toStringMatcher)
protected java.lang.String featureValueOf(T actual)
FeatureMatcher
featureValueOf
in class FeatureMatcher<T,java.lang.String>
actual
- the target objectpublic static <T> Matcher<T> hasToString(Matcher<? super java.lang.String> toStringMatcher)
toString
method
returns a value that satisfies the specified matcher.
For example:
assertThat(true, hasToString(equalTo("TRUE")))
toStringMatcher
- the matcher used to verify the toString resultpublic static <T> Matcher<T> hasToString(java.lang.String expectedToString)
toString
method
returns a value equalTo the specified string.
For example:
assertThat(true, hasToString("TRUE"))
expectedToString
- the expected toString result