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>
- All Implemented Interfaces:
Matcher<T>,SelfDescribing
-
Constructor Summary
Constructors -
Method Summary
Modifier 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.FeatureMatcher
describeTo, matchesSafelyMethods inherited from class org.hamcrest.TypeSafeDiagnosingMatcher
describeMismatch, matchesMethods inherited from class org.hamcrest.BaseMatcher
_dont_implement_Matcher___instead_extend_BaseMatcher_, isNotNull, toString
-
Constructor Details
-
HasToString
-
-
Method Details
-
featureValueOf
Description copied from class:FeatureMatcherImplement this to extract the interesting feature.- Specified by:
featureValueOfin classFeatureMatcher<T,String> - Parameters:
actual- the target object- Returns:
- the feature to be matched
-
hasToString
Creates a matcher that matches any examined object whosetoStringmethod returns a value that satisfies the specified matcher. For example:assertThat(true, hasToString(equalTo("TRUE")))- Parameters:
toStringMatcher- the matcher used to verify the toString result
-
hasToString
Creates a matcher that matches any examined object whosetoStringmethod returns a value equalTo the specified string. For example:assertThat(true, hasToString("TRUE"))- Parameters:
expectedToString- the expected toString result
-