Top Constructors Methods
org.hamcrest.object

public Class HasToString<T>

extends FeatureMatcher<T, String>
Class Inheritance
Imports
org.hamcrest.Factory, .FeatureMatcher, .Matcher

Constructor Summary

AccessConstructor and Description
public
HasToString(Matcher<? super String> toStringMatcher)

Method Summary

Modifier and TypeMethod and Description
protected String
featureValueOf(T
the target object
actual
)

Implements abstract org.hamcrest.FeatureMatcher.featureValueOf.

Implement this to extract the interesting feature.
public static <T> Matcher<T>
hasToString(Matcher<? super String>
the matcher used to verify the toString result
toStringMatcher
)

Creates a matcher that matches any examined object whose toString method returns a value that satisfies the specified matcher.

public static <T> Matcher<T>
hasToString(String
the expected toString result
expectedToString
)

Creates a matcher that matches any examined object whose toString method returns a value equalTo the specified string.

Inherited from org.hamcrest.FeatureMatcher:
describeTomatchesSafely

Constructor Detail

HasToStringback to summary
public HasToString(Matcher<? super String> toStringMatcher)

Method Detail

featureValueOfback to summary
protected String featureValueOf(T actual)

Implements abstract org.hamcrest.FeatureMatcher.featureValueOf.

Doc from org.hamcrest.FeatureMatcher.featureValueOf.

Implement this to extract the interesting feature.

Parameters
actual:T

the target object

Returns:String

the feature to be matched

Annotations
@Override
hasToStringback to summary
public static <T> Matcher<T> hasToString(Matcher<? super String> toStringMatcher)

Creates a matcher that matches any examined object whose toString method returns a value that satisfies the specified matcher.

For example:

assertThat(true, hasToString(equalTo("TRUE")))
Parameters
toStringMatcher:Matcher<? super String>

the matcher used to verify the toString result

Annotations
@Factory
hasToStringback to summary
public static <T> Matcher<T> hasToString(String expectedToString)

Creates a matcher that matches any examined object whose toString method returns a value equalTo the specified string.

For example:

assertThat(true, hasToString("TRUE"))
Parameters
expectedToString:String

the expected toString result

Annotations
@Factory