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
Class Parameterized

    java.lang.Object
      org.junit.runner.Runner
          org.junit.runners.ParentRunner<Runner>
              org.junit.runners.Suite
                  org.junit.runners.Parameterized

All Implemented Interfaces:
  Describable, Filterable, Sortable

    public class Parameterized

extends Suite

The custom runner `Parameterized` implements parameterized tests. When running a parameterized test class, instances are created for the cross-product of the test methods and the test data elements.

For example, to test a Fibonacci function, write:

     @RunWith(Parameterized.class)
     public class FibonacciTest {
            @Parameters
            public static List<Object[]> data() {
                    return Arrays.asList(new Object[][] {
                                    Fibonacci,
                                    { { 0, 0 }, { 1, 1 }, { 2, 1 }, { 3, 2 }, { 4, 3 }, { 5, 5 },
                                                    { 6, 8 } } });
            }

            private int fInput;

            private int fExpected;

            public FibonacciTest(int input, int expected) {
                    fInput= input;
                    fExpected= expected;
            }

            @Test
            public void test() {
                    assertEquals(fExpected, Fibonacci.compute(fInput));
            }
     }

Each instance of `FibonacciTest` will be constructed using the two-argument constructor and the data values in the `@Parameters` method.

Nested Class Summary
`static interface` | `Parameterized.Parameters` Annotation for a method which provides parameters to be injected into the test class constructor by `Parameterized`

Nested classes/interfaces inherited from class org.junit.runners.Suite
`Suite.SuiteClasses`

Constructor Summary
`Parameterized(Class<?> klass)` Only called reflectively.

Method Summary
`protected List<Runner>` | `getChildren()` Returns a list of objects that define the children of this Runner.

Methods inherited from class org.junit.runners.Suite
`describeChild, emptySuite, runChild`

Methods inherited from class org.junit.runners.ParentRunner
`childrenInvoker, classBlock, collectInitializationErrors, filter, getDescription, getName, getTestClass, run, setScheduler, sort, validatePublicVoidNoArgMethods, withAfterClasses, withBeforeClasses`

Methods inherited from class org.junit.runner.Runner
`testCount`

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

Constructor Detail

### Parameterized

    public Parameterized(Class<?> klass)
                  throws Throwable

  Only called reflectively. Do not use programmatically.

  Throws:
    `Throwable`

Method Detail

### getChildren

    protected List<Runner> getChildren()

  Description copied from class: `ParentRunner`
  Returns a list of objects that define the children of this Runner.

  Overrides:
    `getChildren` in class `Suite`

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