Class StringContains

All Implemented Interfaces:
Matcher<String>, SelfDescribing

public class StringContains extends SubstringMatcher
Tests if the argument is a string that contains a specific substring.
  • Constructor Details

  • Method Details

    • evalSubstringOf

      protected boolean evalSubstringOf(String s)
      Description copied from class: SubstringMatcher
      Checks if the input matches the specific substring.
      Specified by:
      evalSubstringOf in class SubstringMatcher
      Parameters:
      s - the string to check
      Returns:
      the result of the match
    • 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
      Returns:
      The matcher.
    • containsStringIgnoringCase

      public static Matcher<String> containsStringIgnoringCase(String substring)
      Creates a matcher that matches if the examined String contains the specified String anywhere, 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.