Skip to content

Better message if assertThat(string).matches(equalString) fails #783

@cpovirk

Description

@cpovirk

As noted in https://stackoverflow.com/q/64616887/28465, it's easy for users to write matches when they mean isEqualTo. (Perhaps we should have picked a name like "matchesRegex"; oops [edit: probably "matchesPattern," a colleague points out].) If someone writes matches("$5") and the input string is "$5," our failure message could say "Hey, that doesn't match the regex, but did you mean isEqualTo?"

(If users make this mistake with doesNotMatch, there's usually not much we can do to detect it, since the test just passes silently....)

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3not scheduledtype=enhancementMake an existing feature better

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions