Package org.junit.runners
Class Suite
- java.lang.Object
-
- org.junit.runner.Runner
-
- org.junit.runners.ParentRunner<Runner>
-
- org.junit.runners.Suite
-
- All Implemented Interfaces:
Describable,Filterable,Orderable,Sortable
- Direct Known Subclasses:
Categories,Enclosed,Parameterized
public class Suite extends ParentRunner<Runner>
UsingSuiteas a runner allows you to manually build a suite containing tests from many classes. It is the JUnit 4 equivalent of the JUnit 3.8.x staticTestsuite()method. To use it, annotate a class with@RunWith(Suite.class)and@SuiteClasses({TestClass1.class, ...}). When you run this class, it will run all the tests in all the suite classes.- Since:
- 4.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceSuite.SuiteClassesTheSuiteClassesannotation specifies the classes to be run when a class annotated with@RunWith(Suite.class)is run.
-
Constructor Summary
Constructors Modifier Constructor Description protectedSuite(java.lang.Class<?> klass, java.lang.Class<?>[] suiteClasses)Call this when the default builder is good enough.protectedSuite(java.lang.Class<?> klass, java.util.List<Runner> runners)Called by this class and subclasses once the runners making up the suite have been determinedSuite(java.lang.Class<?> klass, RunnerBuilder builder)Called reflectively on classes annotated with@RunWith(Suite.class)Suite(RunnerBuilder builder, java.lang.Class<?>[] classes)Call this when there is no single root class (for example, multiple class names passed on the command line toJUnitCoreprotectedSuite(RunnerBuilder builder, java.lang.Class<?> klass, java.lang.Class<?>[] suiteClasses)Called by this class and subclasses once the classes making up the suite have been determined
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected DescriptiondescribeChild(Runner child)Returns aDescriptionforchild, which can be assumed to be an element of the list returned byParentRunner.getChildren()static RunneremptySuite()Returns an empty suite.private static java.lang.Class<?>[]getAnnotatedClasses(java.lang.Class<?> klass)protected java.util.List<Runner>getChildren()Returns a list of objects that define the children of this Runner.protected voidrunChild(Runner runner, RunNotifier notifier)Runs the test corresponding tochild, which can be assumed to be an element of the list returned byParentRunner.getChildren().-
Methods inherited from class org.junit.runners.ParentRunner
childrenInvoker, classBlock, classRules, collectInitializationErrors, createTestClass, filter, getDescription, getName, getRunnerAnnotations, getTestClass, isIgnored, order, run, runLeaf, setScheduler, sort, validatePublicVoidNoArgMethods, withAfterClasses, withBeforeClasses, withInterruptIsolation
-
-
-
-
Field Detail
-
runners
private final java.util.List<Runner> runners
-
-
Constructor Detail
-
Suite
public Suite(java.lang.Class<?> klass, RunnerBuilder builder) throws InitializationErrorCalled reflectively on classes annotated with@RunWith(Suite.class)- Parameters:
klass- the root classbuilder- builds runners for classes in the suite- Throws:
InitializationError
-
Suite
public Suite(RunnerBuilder builder, java.lang.Class<?>[] classes) throws InitializationError
Call this when there is no single root class (for example, multiple class names passed on the command line toJUnitCore- Parameters:
builder- builds runners for classes in the suiteclasses- the classes in the suite- Throws:
InitializationError
-
Suite
protected Suite(java.lang.Class<?> klass, java.lang.Class<?>[] suiteClasses) throws InitializationErrorCall this when the default builder is good enough. Left in for compatibility with JUnit 4.4.- Parameters:
klass- the root of the suitesuiteClasses- the classes in the suite- Throws:
InitializationError
-
Suite
protected Suite(RunnerBuilder builder, java.lang.Class<?> klass, java.lang.Class<?>[] suiteClasses) throws InitializationError
Called by this class and subclasses once the classes making up the suite have been determined- Parameters:
builder- builds runners for classes in the suiteklass- the root of the suitesuiteClasses- the classes in the suite- Throws:
InitializationError
-
Suite
protected Suite(java.lang.Class<?> klass, java.util.List<Runner> runners) throws InitializationErrorCalled by this class and subclasses once the runners making up the suite have been determined- Parameters:
klass- root of the suiterunners- for each class in the suite, aRunner- Throws:
InitializationError
-
-
Method Detail
-
emptySuite
public static Runner emptySuite()
Returns an empty suite.
-
getAnnotatedClasses
private static java.lang.Class<?>[] getAnnotatedClasses(java.lang.Class<?> klass) throws InitializationError- Throws:
InitializationError
-
getChildren
protected java.util.List<Runner> getChildren()
Description copied from class:ParentRunnerReturns a list of objects that define the children of this Runner.- Specified by:
getChildrenin classParentRunner<Runner>
-
describeChild
protected Description describeChild(Runner child)
Description copied from class:ParentRunnerReturns aDescriptionforchild, which can be assumed to be an element of the list returned byParentRunner.getChildren()- Specified by:
describeChildin classParentRunner<Runner>
-
runChild
protected void runChild(Runner runner, RunNotifier notifier)
Description copied from class:ParentRunnerRuns the test corresponding tochild, which can be assumed to be an element of the list returned byParentRunner.getChildren(). Subclasses are responsible for making sure that relevant test events are reported throughnotifier- Specified by:
runChildin classParentRunner<Runner>
-
-