RunnerBuilder (JUnit API)
Date: 2011-08-22

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.junit.runners.model
Class RunnerBuilder

    java.lang.Object
      org.junit.runners.model.RunnerBuilder

    public abstract class RunnerBuilder

extends Object

A RunnerBuilder is a strategy for constructing runners for classes. Only writers of custom runners should use `RunnerBuilder`s. A custom runner class with a constructor taking a `RunnerBuilder` parameter will be passed the instance of `RunnerBuilder` used to build that runner itself. For example, imagine a custom runner that builds suites based on a list of classes in a text file:

     \@RunWith(TextFileSuite.class)
     \@SuiteSpecFile("mysuite.txt")
     class MySuite {}

The implementation of TextFileSuite might include:

     public TextFileSuite(Class testClass, RunnerBuilder builder) {
       // ...
       for (String className : readClassNames())
         addRunner(builder.runnerForClass(Class.forName(className)));
       // ...
     }

See Also:
  `Suite`

Constructor Summary
`RunnerBuilder()`

Method Summary
`abstract Runner` | `runnerForClass(Class<?> testClass)` Override to calculate the correct runner for a test class at runtime.
`List<Runner>` | `runners(Class<?> parent, Class<?>[] children)` Constructs and returns a list of Runners, one for each child class in `children`.
`List<Runner>` | `runners(Class<?> parent, List<Class<?>> children)`
`Runner` | `safeRunnerForClass(Class<?> testClass)` Always returns a runner, even if it is just one that prints an error instead of running tests.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### RunnerBuilder

    public RunnerBuilder()

Method Detail

### runnerForClass

    public abstract Runner runnerForClass(Class<?> testClass)
                                   throws Throwable

  Override to calculate the correct runner for a test class at runtime.

  Parameters:
    `testClass` - class to be run
  Returns:
    a Runner
  Throws:
    `Throwable` - if a runner cannot be constructed

### safeRunnerForClass

    public Runner safeRunnerForClass(Class<?> testClass)

  Always returns a runner, even if it is just one that prints an error instead of running tests.

  Parameters:
    `testClass` - class to be run
  Returns:
    a Runner

### runners

    public List<Runner> runners(Class<?> parent,
                                Class<?>[] children)
                         throws InitializationError

  Constructs and returns a list of Runners, one for each child class in `children`. Care is taken to avoid infinite recursion: this builder will throw an exception if it is requested for another runner for `parent` before this call completes.

  Throws:
    `InitializationError`

### runners

    public List<Runner> runners(Class<?> parent,
                                List<Class<?>> children)
                         throws InitializationError

  Throws:
    `InitializationError`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD