Package org.hamcrest.core
Class StringContains
java.lang.Object
org.hamcrest.BaseMatcher<String>
org.hamcrest.TypeSafeMatcher<String>
org.hamcrest.core.SubstringMatcher
org.hamcrest.core.StringContains
- All Implemented Interfaces:
Matcher<String>,SelfDescribing
Tests if the argument is a string that contains a specific substring.
-
Field Summary
Fields inherited from class org.hamcrest.core.SubstringMatcher
substring -
Constructor Summary
ConstructorsConstructorDescriptionStringContains(boolean ignoringCase, String substring) Constructor, best used withcontainsString(String)orcontainsStringIgnoringCase(String).StringContains(String substring) Constructor, best used withcontainsString(String). -
Method Summary
Modifier and TypeMethodDescriptioncontainsString(String substring) containsStringIgnoringCase(String substring) protected booleanChecks if the input matches the specific substring.Methods inherited from class org.hamcrest.core.SubstringMatcher
converted, describeMismatchSafely, describeTo, matchesSafelyMethods inherited from class org.hamcrest.TypeSafeMatcher
describeMismatch, matchesMethods inherited from class org.hamcrest.BaseMatcher
_dont_implement_Matcher___instead_extend_BaseMatcher_, isNotNull, toString
-
Constructor Details
-
StringContains
Constructor, best used withcontainsString(String).- Parameters:
substring- the expected substring.
-
StringContains
Constructor, best used withcontainsString(String)orcontainsStringIgnoringCase(String).- Parameters:
ignoringCase- whether to ignore case when matchingsubstring- the expected substring.
-
-
Method Details
-
evalSubstringOf
Description copied from class:SubstringMatcherChecks if the input matches the specific substring.- Specified by:
evalSubstringOfin classSubstringMatcher- Parameters:
s- the string to check- Returns:
- the result of the match
-
containsString
Creates a matcher that matches if the examinedStringcontains the specifiedStringanywhere. For example:assertThat("myStringOfNote", containsString("ring"))- Parameters:
substring- the substring that the returned matcher will expect to find within any examined string- Returns:
- The matcher.
-
containsStringIgnoringCase
Creates a matcher that matches if the examinedStringcontains the specifiedStringanywhere, ignoring case. For example:assertThat("myStringOfNote", containsStringIgnoringCase("Ring"))- Parameters:
substring- the substring that the returned matcher will expect to find within any examined string- Returns:
- The matcher.
-