Improve diagnostics for invalid testGroup values

This commit is contained in:
Chris Beams 2013-02-26 16:10:23 +01:00
parent 1bdd081a14
commit 55caf7bdb0
2 changed files with 11 additions and 3 deletions

View File

@ -21,6 +21,10 @@ import java.util.EnumSet;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import org.springframework.util.StringUtils;
import static java.lang.String.*;
/** /**
* A test group used to limit when certain tests are run. * A test group used to limit when certain tests are run.
* *
@ -64,8 +68,10 @@ public enum TestGroup {
try { try {
groups.add(valueOf(group.trim().toUpperCase())); groups.add(valueOf(group.trim().toUpperCase()));
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
throw new IllegalArgumentException("Unable to find test group '" + group.trim() throw new IllegalArgumentException(format(
+ "' when parsing '" + value + "'"); "Unable to find test group '%s' when parsing testGroups value: '%s'. " +
"Available groups include: [%s]", group.trim(), value,
StringUtils.arrayToCommaDelimitedString(TestGroup.values())));
} }
} }
return groups; return groups;

View File

@ -62,7 +62,9 @@ public class TestGroupTests {
@Test @Test
public void parseMissing() throws Exception { public void parseMissing() throws Exception {
thrown.expect(IllegalArgumentException.class); thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Unable to find test group 'missing' when parsing 'performance, missing'"); thrown.expectMessage("Unable to find test group 'missing' when parsing " +
"testGroups value: 'performance, missing'. Available groups include: " +
"[LONG_RUNNING,PERFORMANCE,JMXMP]");
TestGroup.parse("performance, missing"); TestGroup.parse("performance, missing");
} }