aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/junit/runners/Suite.java
diff options
context:
space:
mode:
authorPaul Duffin <paulduffin@google.com>2016-12-14 11:49:43 +0000
committerPaul Duffin <paulduffin@google.com>2016-12-20 15:52:52 +0000
commitaeb93fc33cae3aadbb9b46083350ad2dc9aea645 (patch)
treeb316db7dee11d1aeee3510562e036fd41705b8b5 /src/main/java/org/junit/runners/Suite.java
parent26401927b83770db45f00706ccc589955644c6c2 (diff)
downloadjunit-aeb93fc33cae3aadbb9b46083350ad2dc9aea645.tar.gz
Upgrade to JUnit 4.12
The license has changed from Common Public License v1.0 to Eclipse Public License v1.0. This will not compile as it is because it is intended to be built against Hamcrest 1.3 or later but it is being built against Hamcrest 1.1. A follow on patch will fix the compilation errors so that it builds against Hamcrest 1.1. That allows Hamcrest to be upgraded separately. The patch can be reverted once Hamcrest has been upgraded. There are also some Android specific issues that will also be fixed in follow on patches. Bug: 33613916 Test: make checkbuild Change-Id: Ic2c983a030399e3ace1a14927cb143fbd8307b4f
Diffstat (limited to 'src/main/java/org/junit/runners/Suite.java')
-rw-r--r--src/main/java/org/junit/runners/Suite.java202
1 files changed, 101 insertions, 101 deletions
diff --git a/src/main/java/org/junit/runners/Suite.java b/src/main/java/org/junit/runners/Suite.java
index 1b3bb48..b37179f 100644
--- a/src/main/java/org/junit/runners/Suite.java
+++ b/src/main/java/org/junit/runners/Suite.java
@@ -5,6 +5,7 @@ import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
+import java.util.Collections;
import java.util.List;
import org.junit.internal.builders.AllDefaultPossibilitiesBuilder;
@@ -20,111 +21,110 @@ import org.junit.runners.model.RunnerBuilder;
* static {@link junit.framework.Test} <code>suite()</code> method. To use it, annotate a class
* with <code>@RunWith(Suite.class)</code> and <code>@SuiteClasses({TestClass1.class, ...})</code>.
* When you run this class, it will run all the tests in all the suite classes.
+ *
+ * @since 4.0
*/
public class Suite extends ParentRunner<Runner> {
- /**
- * Returns an empty suite.
- */
- public static Runner emptySuite() {
- try {
- return new Suite((Class<?>)null, new Class<?>[0]);
- } catch (InitializationError e) {
- throw new RuntimeException("This shouldn't be possible");
- }
- }
-
- /**
- * The <code>SuiteClasses</code> annotation specifies the classes to be run when a class
- * annotated with <code>@RunWith(Suite.class)</code> is run.
- */
- @Retention(RetentionPolicy.RUNTIME)
- @Target(ElementType.TYPE)
- @Inherited
- public @interface SuiteClasses {
- /**
- * @return the classes to be run
- */
- public Class<?>[] value();
- }
-
- private static Class<?>[] getAnnotatedClasses(Class<?> klass) throws InitializationError {
- SuiteClasses annotation= klass.getAnnotation(SuiteClasses.class);
- if (annotation == null)
- throw new InitializationError(String.format("class '%s' must have a SuiteClasses annotation", klass.getName()));
- return annotation.value();
- }
+ /**
+ * Returns an empty suite.
+ */
+ public static Runner emptySuite() {
+ try {
+ return new Suite((Class<?>) null, new Class<?>[0]);
+ } catch (InitializationError e) {
+ throw new RuntimeException("This shouldn't be possible");
+ }
+ }
- private final List<Runner> fRunners;
+ /**
+ * The <code>SuiteClasses</code> annotation specifies the classes to be run when a class
+ * annotated with <code>@RunWith(Suite.class)</code> is run.
+ */
+ @Retention(RetentionPolicy.RUNTIME)
+ @Target(ElementType.TYPE)
+ @Inherited
+ public @interface SuiteClasses {
+ /**
+ * @return the classes to be run
+ */
+ public Class<?>[] value();
+ }
- /**
- * Called reflectively on classes annotated with <code>@RunWith(Suite.class)</code>
- *
- * @param klass the root class
- * @param builder builds runners for classes in the suite
- * @throws InitializationError
- */
- public Suite(Class<?> klass, RunnerBuilder builder) throws InitializationError {
- this(builder, klass, getAnnotatedClasses(klass));
- }
+ private static Class<?>[] getAnnotatedClasses(Class<?> klass) throws InitializationError {
+ SuiteClasses annotation = klass.getAnnotation(SuiteClasses.class);
+ if (annotation == null) {
+ throw new InitializationError(String.format("class '%s' must have a SuiteClasses annotation", klass.getName()));
+ }
+ return annotation.value();
+ }
- /**
- * Call this when there is no single root class (for example, multiple class names
- * passed on the command line to {@link org.junit.runner.JUnitCore}
- *
- * @param builder builds runners for classes in the suite
- * @param classes the classes in the suite
- * @throws InitializationError
- */
- public Suite(RunnerBuilder builder, Class<?>[] classes) throws InitializationError {
- this(null, builder.runners(null, classes));
- }
-
- /**
- * Call this when the default builder is good enough. Left in for compatibility with JUnit 4.4.
- * @param klass the root of the suite
- * @param suiteClasses the classes in the suite
- * @throws InitializationError
- */
- protected Suite(Class<?> klass, Class<?>[] suiteClasses) throws InitializationError {
- this(new AllDefaultPossibilitiesBuilder(true), klass, suiteClasses);
- }
-
- /**
- * Called by this class and subclasses once the classes making up the suite have been determined
- *
- * @param builder builds runners for classes in the suite
- * @param klass the root of the suite
- * @param suiteClasses the classes in the suite
- * @throws InitializationError
- */
- protected Suite(RunnerBuilder builder, Class<?> klass, Class<?>[] suiteClasses) throws InitializationError {
- this(klass, builder.runners(klass, suiteClasses));
- }
-
- /**
- * Called by this class and subclasses once the runners making up the suite have been determined
- *
- * @param klass root of the suite
- * @param runners for each class in the suite, a {@link Runner}
- * @throws InitializationError
- */
- protected Suite(Class<?> klass, List<Runner> runners) throws InitializationError {
- super(klass);
- fRunners = runners;
- }
-
- @Override
- protected List<Runner> getChildren() {
- return fRunners;
- }
-
- @Override
- protected Description describeChild(Runner child) {
- return child.getDescription();
- }
+ private final List<Runner> runners;
- @Override
- protected void runChild(Runner runner, final RunNotifier notifier) {
- runner.run(notifier);
- }
+ /**
+ * Called reflectively on classes annotated with <code>@RunWith(Suite.class)</code>
+ *
+ * @param klass the root class
+ * @param builder builds runners for classes in the suite
+ */
+ public Suite(Class<?> klass, RunnerBuilder builder) throws InitializationError {
+ this(builder, klass, getAnnotatedClasses(klass));
+ }
+
+ /**
+ * Call this when there is no single root class (for example, multiple class names
+ * passed on the command line to {@link org.junit.runner.JUnitCore}
+ *
+ * @param builder builds runners for classes in the suite
+ * @param classes the classes in the suite
+ */
+ public Suite(RunnerBuilder builder, Class<?>[] classes) throws InitializationError {
+ this(null, builder.runners(null, classes));
+ }
+
+ /**
+ * Call this when the default builder is good enough. Left in for compatibility with JUnit 4.4.
+ *
+ * @param klass the root of the suite
+ * @param suiteClasses the classes in the suite
+ */
+ protected Suite(Class<?> klass, Class<?>[] suiteClasses) throws InitializationError {
+ this(new AllDefaultPossibilitiesBuilder(true), klass, suiteClasses);
+ }
+
+ /**
+ * Called by this class and subclasses once the classes making up the suite have been determined
+ *
+ * @param builder builds runners for classes in the suite
+ * @param klass the root of the suite
+ * @param suiteClasses the classes in the suite
+ */
+ protected Suite(RunnerBuilder builder, Class<?> klass, Class<?>[] suiteClasses) throws InitializationError {
+ this(klass, builder.runners(klass, suiteClasses));
+ }
+
+ /**
+ * Called by this class and subclasses once the runners making up the suite have been determined
+ *
+ * @param klass root of the suite
+ * @param runners for each class in the suite, a {@link Runner}
+ */
+ protected Suite(Class<?> klass, List<Runner> runners) throws InitializationError {
+ super(klass);
+ this.runners = Collections.unmodifiableList(runners);
+ }
+
+ @Override
+ protected List<Runner> getChildren() {
+ return runners;
+ }
+
+ @Override
+ protected Description describeChild(Runner child) {
+ return child.getDescription();
+ }
+
+ @Override
+ protected void runChild(Runner runner, final RunNotifier notifier) {
+ runner.run(notifier);
+ }
}