Package org.hamcrest.object
Class HasToString<T>
java.lang.Object
org.hamcrest.BaseMatcher<T>
org.hamcrest.TypeSafeDiagnosingMatcher<T>
org.hamcrest.FeatureMatcher<T,String>
 
org.hamcrest.object.HasToString<T>
- Type Parameters:
- T- The Matcher type.
- All Implemented Interfaces:
- Matcher<T>,- SelfDescribing
A Matcher that checks the output of the 
toString() method.- 
Constructor SummaryConstructorsConstructorDescriptionHasToString(Matcher<? super String> toStringMatcher) Constructor, best called fromhasToString(String)orhasToString(Matcher).
- 
Method SummaryModifier and TypeMethodDescriptionprotected StringfeatureValueOf(T actual) Implement this to extract the interesting feature.static <T> Matcher<T> hasToString(String expectedToString) Creates a matcher that matches any examined object whosetoStringmethod returns a value equalTo the specified string.static <T> Matcher<T> hasToString(Matcher<? super String> toStringMatcher) Creates a matcher that matches any examined object whosetoStringmethod returns a value that satisfies the specified matcher.Methods inherited from class org.hamcrest.FeatureMatcherdescribeTo, matchesSafelyMethods inherited from class org.hamcrest.TypeSafeDiagnosingMatcherdescribeMismatch, matchesMethods inherited from class org.hamcrest.BaseMatcher_dont_implement_Matcher___instead_extend_BaseMatcher_, isNotNull, toString
- 
Constructor Details- 
HasToStringConstructor, best called fromhasToString(String)orhasToString(Matcher).- Parameters:
- toStringMatcher- expected result from calling- toString()
 
 
- 
- 
Method Details- 
featureValueOfDescription copied from class:FeatureMatcherImplement this to extract the interesting feature.- Specified by:
- featureValueOfin class- FeatureMatcher<T,- String> 
- Parameters:
- actual- the target object
- Returns:
- the feature to be matched
 
- 
hasToStringCreates a matcher that matches any examined object whosetoStringmethod returns a value that satisfies the specified matcher. For example:assertThat(true, hasToString(equalTo("TRUE")))- Type Parameters:
- T- the matcher type.
- Parameters:
- toStringMatcher- the matcher used to verify the toString result
- Returns:
- The matcher.
 
- 
hasToStringCreates a matcher that matches any examined object whosetoStringmethod returns a value equalTo the specified string. For example:assertThat(true, hasToString("TRUE"))- Type Parameters:
- T- the matcher type.
- Parameters:
- expectedToString- the expected toString result
- Returns:
- The matcher.
 
 
-