Permalink
Browse files

Description seems to be heading towards Composite. Added "getTestName"

  • Loading branch information...
1 parent c12af8e commit 90bf3119a6326671cc467386036302cc6040f752 kbeck committed Dec 20, 2008
View
@@ -7,3 +7,4 @@ buildfile
java.hprof.txt
junit4.5-RC1
junit4.*
+*.ser
@@ -198,24 +198,37 @@ public Description childlessCopy() {
}
// TODO (Nov 18, 2008 1:55:31 PM): do we want this here?
+ // This seems like reasonable API once we "Composite-ize" Description
public Class<?> parseClass() {
- Matcher matcher= Pattern.compile("(.*)\\((.*)\\)").matcher(toString());
- if (matcher.matches())
- try {
- return Class.forName(matcher.group(2));
- } catch (ClassNotFoundException e) {
+ String name= getClassName();
+ if (name == null)
+ return null;
+ try {
+ return Class.forName(name);
+ } catch (ClassNotFoundException e) {
// TODO (Nov 18, 2008 1:54:36 PM): something better
- e.printStackTrace();
- }
- return null;
+ e.printStackTrace();
+ return null;
+ }
}
- public String parseMethod() {
+ public String getClassName() {
+ Matcher matcher= Pattern.compile("(.*)\\((.*)\\)").matcher(toString());
+ return matcher.matches()
+ ? matcher.group(2)
+ : null;
+ }
+
+ private String parseMethod() {
Matcher matcher= Pattern.compile("(.*)\\((.*)\\)").matcher(toString());
if (matcher.matches())
return matcher.group(1);
return null;
}
+
+ public String getMethodName() {
+ return parseMethod();
+ }
// TODO (Nov 18, 2008 1:59:37 PM): circular
public Runner buildRunner() {
@@ -1,4 +1,4 @@
-package org.junit.runners.model;
+package org.junit.runners.model;
import java.lang.annotation.Annotation;
import java.lang.reflect.InvocationTargetException;
@@ -252,7 +252,7 @@ public void parseClass_whenCantParse() {
@Test
public void parseMethod_whenCantParse() {
- assertNull(Description.TEST_MECHANISM.parseMethod());
+ assertNull(Description.TEST_MECHANISM.getMethodName());
}
@Test

0 comments on commit 90bf311

Please sign in to comment.