aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/junit/framework/TestSuite.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/junit/framework/TestSuite.java')
-rw-r--r--src/main/java/junit/framework/TestSuite.java29
1 files changed, 9 insertions, 20 deletions
diff --git a/src/main/java/junit/framework/TestSuite.java b/src/main/java/junit/framework/TestSuite.java
index 366f1cf..50cd5f8 100644
--- a/src/main/java/junit/framework/TestSuite.java
+++ b/src/main/java/junit/framework/TestSuite.java
@@ -1,7 +1,5 @@
package junit.framework;
-import java.io.PrintWriter;
-import java.io.StringWriter;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@@ -12,6 +10,7 @@ import java.util.List;
import java.util.Vector;
import org.junit.internal.MethodSorter;
+import org.junit.internal.Throwables;
/**
* A <code>TestSuite</code> is a <code>Composite</code> of Tests.
@@ -35,7 +34,7 @@ import org.junit.internal.MethodSorter;
* <p>
* A final option is to do the same for a large array of test classes.
* <pre>
- * Class[] testClasses = { MathTest.class, AnotherTest.class }
+ * Class[] testClasses = { MathTest.class, AnotherTest.class };
* TestSuite suite= new TestSuite(testClasses);
* </pre>
*
@@ -65,11 +64,11 @@ public class TestSuite implements Test {
test = constructor.newInstance(new Object[]{name});
}
} catch (InstantiationException e) {
- return (warning("Cannot instantiate test case: " + name + " (" + exceptionToString(e) + ")"));
+ return (warning("Cannot instantiate test case: " + name + " (" + Throwables.getStacktrace(e) + ")"));
} catch (InvocationTargetException e) {
- return (warning("Exception in constructor: " + name + " (" + exceptionToString(e.getTargetException()) + ")"));
+ return (warning("Exception in constructor: " + name + " (" + Throwables.getStacktrace(e.getTargetException()) + ")"));
} catch (IllegalAccessException e) {
- return (warning("Cannot access test case: " + name + " (" + exceptionToString(e) + ")"));
+ return (warning("Cannot access test case: " + name + " (" + Throwables.getStacktrace(e) + ")"));
}
return (Test) test;
}
@@ -99,16 +98,6 @@ public class TestSuite implements Test {
};
}
- /**
- * Converts the stack trace into a string
- */
- private static String exceptionToString(Throwable e) {
- StringWriter stringWriter = new StringWriter();
- PrintWriter writer = new PrintWriter(stringWriter);
- e.printStackTrace(writer);
- return stringWriter.toString();
- }
-
private String fName;
private Vector<Test> fTests = new Vector<Test>(10); // Cannot convert this to List because it is used directly by some test runners
@@ -210,7 +199,7 @@ public class TestSuite implements Test {
}
/**
- * Adds the tests from the given class to the suite
+ * Adds the tests from the given class to the suite.
*/
public void addTestSuite(Class<? extends TestCase> testClass) {
addTest(new TestSuite(testClass));
@@ -262,21 +251,21 @@ public class TestSuite implements Test {
}
/**
- * Returns the test at the given index
+ * Returns the test at the given index.
*/
public Test testAt(int index) {
return fTests.get(index);
}
/**
- * Returns the number of tests in this suite
+ * Returns the number of tests in this suite.
*/
public int testCount() {
return fTests.size();
}
/**
- * Returns the tests as an enumeration
+ * Returns the tests as an enumeration.
*/
public Enumeration<Test> tests() {
return fTests.elements();