google/truth

Deprecate StringSubject.doesNotMatch?

cpovirk opened this issue · 0 comments

As noted in #789 (comment), it's very frequently misused.

Users who want that behavior would likely be better served by having to opt into it more explicitly with a call like doesNotContainMatch("(?s)^.*something.*$"). Unfortunately, even that is likely to lead to misuse: If users omit (?s), then . does not match newlines, so any string with a newline will pass a test like doesNotContainMatch("^.*something.*$") :( Perhaps our regex methods would ideally have enabled (?s) by default. But then that would be different from the Pattern-accepting overloads. There is no great solution here.