From 55caf7bdb0b418d64967f057832eba40de7ff825 Mon Sep 17 00:00:00 2001 From: Chris Beams Date: Tue, 26 Feb 2013 16:10:23 +0100 Subject: [PATCH] Improve diagnostics for invalid testGroup values --- .../test/java/org/springframework/tests/TestGroup.java | 10 ++++++++-- .../java/org/springframework/tests/TestGroupTests.java | 4 +++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/spring-core/src/test/java/org/springframework/tests/TestGroup.java b/spring-core/src/test/java/org/springframework/tests/TestGroup.java index dcc376eea4..7bd0ccdfd5 100644 --- a/spring-core/src/test/java/org/springframework/tests/TestGroup.java +++ b/spring-core/src/test/java/org/springframework/tests/TestGroup.java @@ -21,6 +21,10 @@ import java.util.EnumSet; import java.util.HashSet; 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. * @@ -64,8 +68,10 @@ public enum TestGroup { try { groups.add(valueOf(group.trim().toUpperCase())); } catch (IllegalArgumentException e) { - throw new IllegalArgumentException("Unable to find test group '" + group.trim() - + "' when parsing '" + value + "'"); + throw new IllegalArgumentException(format( + "Unable to find test group '%s' when parsing testGroups value: '%s'. " + + "Available groups include: [%s]", group.trim(), value, + StringUtils.arrayToCommaDelimitedString(TestGroup.values()))); } } return groups; diff --git a/spring-core/src/test/java/org/springframework/tests/TestGroupTests.java b/spring-core/src/test/java/org/springframework/tests/TestGroupTests.java index 2b4860fd72..7f9fe924c4 100644 --- a/spring-core/src/test/java/org/springframework/tests/TestGroupTests.java +++ b/spring-core/src/test/java/org/springframework/tests/TestGroupTests.java @@ -62,7 +62,9 @@ public class TestGroupTests { @Test public void parseMissing() throws Exception { 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"); }