Class StringStartsWith

  • All Implemented Interfaces:
    Matcher<java.lang.String>, SelfDescribing

    public class StringStartsWith
    extends SubstringMatcher
    Tests if the argument is a string that starts with a specific substring.
    • Constructor Detail

      • StringStartsWith

        public StringStartsWith​(java.lang.String substring)
      • StringStartsWith

        public StringStartsWith​(boolean ignoringCase,
                                java.lang.String substring)
    • Method Detail

      • startsWith

        public static Matcher<java.lang.String> startsWith​(java.lang.String prefix)

        Creates a matcher that matches if the examined String starts with the specified String.

        For example:
        assertThat("myStringOfNote", startsWith("my"))
        Parameters:
        prefix - the substring that the returned matcher will expect at the start of any examined string
        Returns:
        The matcher.
      • startsWithIgnoringCase

        public static Matcher<java.lang.String> startsWithIgnoringCase​(java.lang.String prefix)

        Creates a matcher that matches if the examined String starts with the specified String, ignoring case

        For example:
        assertThat("myStringOfNote", startsWithIgnoringCase("My"))
        Parameters:
        prefix - the substring that the returned matcher will expect at the start of any examined string
        Returns:
        The matcher.