Package org.junit.runners.parameterized
Class BlockJUnit4ClassRunnerWithParameters
- java.lang.Object
-
- org.junit.runner.Runner
-
- org.junit.runners.ParentRunner<FrameworkMethod>
-
- org.junit.runners.BlockJUnit4ClassRunner
-
- org.junit.runners.parameterized.BlockJUnit4ClassRunnerWithParameters
-
- All Implemented Interfaces:
Describable,Filterable,Orderable,Sortable
public class BlockJUnit4ClassRunnerWithParameters extends BlockJUnit4ClassRunner
ABlockJUnit4ClassRunnerwith parameters support. Parameters can be injected via constructor or into annotated fields.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classBlockJUnit4ClassRunnerWithParameters.InjectionTypeprivate classBlockJUnit4ClassRunnerWithParameters.RunAfterParamsprivate classBlockJUnit4ClassRunnerWithParameters.RunBeforeParams
-
Field Summary
Fields Modifier and Type Field Description private java.lang.Stringnameprivate java.lang.Object[]parameters
-
Constructor Summary
Constructors Constructor Description BlockJUnit4ClassRunnerWithParameters(TestWithParameters test)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected StatementclassBlock(RunNotifier notifier)Constructs aStatementto run all of the tests in the test class.java.lang.ObjectcreateTest()Returns a new fixture for running a test.private java.lang.ObjectcreateTestUsingConstructorInjection()private java.lang.ObjectcreateTestUsingFieldInjection()private booleanfieldsAreAnnotated()private java.util.List<FrameworkField>getAnnotatedFieldsByParameter()private BlockJUnit4ClassRunnerWithParameters.InjectionTypegetInjectionType()protected java.lang.StringgetName()Returns a name used to describe this Runnerprotected java.lang.annotation.Annotation[]getRunnerAnnotations()protected java.lang.StringtestName(FrameworkMethod method)Returns the name that describesmethodforDescriptions.protected voidvalidateConstructor(java.util.List<java.lang.Throwable> errors)Adds toerrorsif the test class has more than one constructor, or if the constructor takes parameters.protected voidvalidateFields(java.util.List<java.lang.Throwable> errors)private StatementwithAfterParams(Statement statement)private StatementwithBeforeParams(Statement statement)-
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
-
-
-
-
Constructor Detail
-
BlockJUnit4ClassRunnerWithParameters
public BlockJUnit4ClassRunnerWithParameters(TestWithParameters test) throws InitializationError
- Throws:
InitializationError
-
-
Method Detail
-
createTest
public java.lang.Object createTest() throws java.lang.ExceptionDescription copied from class:BlockJUnit4ClassRunnerReturns a new fixture for running a test. Default implementation executes the test class's no-argument constructor (validation should have ensured one exists).- Overrides:
createTestin classBlockJUnit4ClassRunner- Throws:
java.lang.Exception
-
createTestUsingConstructorInjection
private java.lang.Object createTestUsingConstructorInjection() throws java.lang.Exception- Throws:
java.lang.Exception
-
createTestUsingFieldInjection
private java.lang.Object createTestUsingFieldInjection() throws java.lang.Exception- Throws:
java.lang.Exception
-
getName
protected java.lang.String getName()
Description copied from class:ParentRunnerReturns a name used to describe this Runner- Overrides:
getNamein classParentRunner<FrameworkMethod>
-
testName
protected java.lang.String testName(FrameworkMethod method)
Description copied from class:BlockJUnit4ClassRunnerReturns the name that describesmethodforDescriptions. Default implementation is the method's name- Overrides:
testNamein classBlockJUnit4ClassRunner
-
validateConstructor
protected void validateConstructor(java.util.List<java.lang.Throwable> errors)
Description copied from class:BlockJUnit4ClassRunnerAdds toerrorsif the test class has more than one constructor, or if the constructor takes parameters. Override if a subclass requires different validation rules.- Overrides:
validateConstructorin classBlockJUnit4ClassRunner
-
validateFields
protected void validateFields(java.util.List<java.lang.Throwable> errors)
- Overrides:
validateFieldsin classBlockJUnit4ClassRunner
-
classBlock
protected Statement classBlock(RunNotifier notifier)
Description copied from class:ParentRunnerConstructs aStatementto run all of the tests in the test class. Override to add pre-/post-processing. Here is an outline of the implementation:- Determine the children to be run using
ParentRunner.getChildren()(subject to any imposed filter and sort). - If there are any children remaining after filtering and ignoring,
construct a statement that will:
- Apply all
ClassRules on the test-class and superclasses. - Run all non-overridden
@BeforeClassmethods on the test-class and superclasses; if any throws an Exception, stop execution and pass the exception on. - Run all remaining tests on the test-class.
- Run all non-overridden
@AfterClassmethods on the test-class and superclasses: exceptions thrown by previous steps are combined, if necessary, with exceptions from AfterClass methods into aMultipleFailureException.
- Apply all
- Overrides:
classBlockin classParentRunner<FrameworkMethod>- Returns:
Statement
- Determine the children to be run using
-
getRunnerAnnotations
protected java.lang.annotation.Annotation[] getRunnerAnnotations()
- Overrides:
getRunnerAnnotationsin classParentRunner<FrameworkMethod>- Returns:
- the annotations that should be attached to this runner's description.
-
getAnnotatedFieldsByParameter
private java.util.List<FrameworkField> getAnnotatedFieldsByParameter()
-
getInjectionType
private BlockJUnit4ClassRunnerWithParameters.InjectionType getInjectionType()
-
fieldsAreAnnotated
private boolean fieldsAreAnnotated()
-
-