org.hamcrest.core
Class StringContains
java.lang.Object
org.hamcrest.BaseMatcher<T>
org.hamcrest.TypeSafeMatcher<String>
org.hamcrest.core.SubstringMatcher
org.hamcrest.core.StringContains
- All Implemented Interfaces:
- Matcher<String>, SelfDescribing
public class StringContains
- extends SubstringMatcher
Tests if the argument is a string that contains a substring.
StringContains
public StringContains(String substring)
evalSubstringOf
protected boolean evalSubstringOf(String s)
- Specified by:
evalSubstringOf
in class SubstringMatcher
relationship
protected String relationship()
- Specified by:
relationship
in class SubstringMatcher
containsString
public static Matcher<String> containsString(String substring)
- Creates a matcher that matches if the examined
String
contains the specified
String
anywhere.
For example:
assertThat("myStringOfNote", containsString("ring"))
- Parameters:
substring
- the substring that the returned matcher will expect to find within any examined string