org.junit.runners.parameterized
Class BlockJUnit4ClassRunnerWithParameters

java.lang.Object
  extended by org.junit.runner.Runner
      extended by org.junit.runners.ParentRunner<FrameworkMethod>
          extended by org.junit.runners.BlockJUnit4ClassRunner
              extended by org.junit.runners.parameterized.BlockJUnit4ClassRunnerWithParameters
All Implemented Interfaces:
Describable, Filterable, Orderable, Sortable

public class BlockJUnit4ClassRunnerWithParameters
extends BlockJUnit4ClassRunner

A BlockJUnit4ClassRunner with parameters support. Parameters can be injected via constructor or into annotated fields.


Constructor Summary
BlockJUnit4ClassRunnerWithParameters(TestWithParameters test)
           
 
Method Summary
protected  Statement classBlock(RunNotifier notifier)
          Constructs a Statement to run all of the tests in the test class.
 Object createTest()
          Returns a new fixture for running a test.
protected  String getName()
          Returns a name used to describe this Runner
protected  Annotation[] getRunnerAnnotations()
           
protected  String testName(FrameworkMethod method)
          Returns the name that describes method for Descriptions.
protected  void validateConstructor(List<Throwable> errors)
          Adds to errors if the test class has more than one constructor, or if the constructor takes parameters.
protected  void validateFields(List<Throwable> errors)
           
 
Methods inherited from class org.junit.runners.BlockJUnit4ClassRunner
collectInitializationErrors, computeTestMethods, createTest, describeChild, getChildren, getTestRules, isIgnored, methodBlock, methodInvoker, possiblyExpectingExceptions, rules, runChild, validateInstanceMethods, validateNoNonStaticInnerClass, validateOnlyOneConstructor, validateTestMethods, validateZeroArgConstructor, withAfters, withBefores, withPotentialTimeout
 
Methods inherited from class org.junit.runners.ParentRunner
childrenInvoker, classRules, createTestClass, filter, getDescription, getTestClass, order, run, runLeaf, setScheduler, sort, validatePublicVoidNoArgMethods, withAfterClasses, withBeforeClasses, withInterruptIsolation
 
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

BlockJUnit4ClassRunnerWithParameters

public BlockJUnit4ClassRunnerWithParameters(TestWithParameters test)
                                     throws InitializationError
Throws:
InitializationError
Method Detail

createTest

public Object createTest()
                  throws Exception
Description copied from class: BlockJUnit4ClassRunner
Returns a new fixture for running a test. Default implementation executes the test class's no-argument constructor (validation should have ensured one exists).

Overrides:
createTest in class BlockJUnit4ClassRunner
Throws:
Exception

getName

protected String getName()
Description copied from class: ParentRunner
Returns a name used to describe this Runner

Overrides:
getName in class ParentRunner<FrameworkMethod>

testName

protected String testName(FrameworkMethod method)
Description copied from class: BlockJUnit4ClassRunner
Returns the name that describes method for Descriptions. Default implementation is the method's name

Overrides:
testName in class BlockJUnit4ClassRunner

validateConstructor

protected void validateConstructor(List<Throwable> errors)
Description copied from class: BlockJUnit4ClassRunner
Adds to errors if the test class has more than one constructor, or if the constructor takes parameters. Override if a subclass requires different validation rules.

Overrides:
validateConstructor in class BlockJUnit4ClassRunner

validateFields

protected void validateFields(List<Throwable> errors)
Overrides:
validateFields in class BlockJUnit4ClassRunner

classBlock

protected Statement classBlock(RunNotifier notifier)
Description copied from class: ParentRunner
Constructs a Statement to run all of the tests in the test class. Override to add pre-/post-processing. Here is an outline of the implementation:
  1. Determine the children to be run using ParentRunner.getChildren() (subject to any imposed filter and sort).
  2. If there are any children remaining after filtering and ignoring, construct a statement that will:
    1. Apply all ClassRules on the test-class and superclasses.
    2. Run all non-overridden @BeforeClass methods on the test-class and superclasses; if any throws an Exception, stop execution and pass the exception on.
    3. Run all remaining tests on the test-class.
    4. Run all non-overridden @AfterClass methods on the test-class and superclasses: exceptions thrown by previous steps are combined, if necessary, with exceptions from AfterClass methods into a MultipleFailureException.

Overrides:
classBlock in class ParentRunner<FrameworkMethod>
Returns:
Statement

getRunnerAnnotations

protected Annotation[] getRunnerAnnotations()
Overrides:
getRunnerAnnotations in class ParentRunner<FrameworkMethod>
Returns:
the annotations that should be attached to this runner's description.


Copyright © 2002–2021 JUnit. All rights reserved.