I think the expectedRegex and expectedRegexPattern parameters used here should be guarded, rather than throwing MatchesException.