From 8e80a2a7b89329f95cb41e8b2981044362478c04 Mon Sep 17 00:00:00 2001 From: Pete Bentley Date: Sun, 21 Feb 2021 18:26:28 +0000 Subject: Upgrade external/junit to 4.13.2 Contains just the changes from 4.12 to 4.13.2 and undoes local Android changes. Will re-patch those in in subsequent CLs. This change re-lands https://r.android.com/1598413. Bug: 129054170 Test: m Change-Id: I6135799c8be5db2ec4c3f13951c18c072427e30d --- src/main/java/junit/framework/TestSuite.java | 29 +++++++++------------------- 1 file changed, 9 insertions(+), 20 deletions(-) (limited to 'src/main/java/junit/framework/TestSuite.java') 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 TestSuite is a Composite of Tests. @@ -35,7 +34,7 @@ import org.junit.internal.MethodSorter; *

* A final option is to do the same for a large array of test classes. *

- * Class[] testClasses = { MathTest.class, AnotherTest.class }
+ * Class[] testClasses = { MathTest.class, AnotherTest.class };
  * TestSuite suite= new TestSuite(testClasses);
  * 
* @@ -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 fTests = new Vector(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 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 tests() { return fTests.elements(); -- cgit v1.2.3