void (String... expectedMessages) { Set<String> expected = ContainerUtil.newHashSet(expectedMessages); outer: for (String problem : myProblems) { for (String message : expected) { if (problem.contains(message)) { expected.remove(message); continue outer; } } fail("Unexpected problem: " + problem); } if (!expected.isEmpty()) { fail("The following problems are not reported: " + StringUtil.join(expected, "; ")); } }