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
A
BlockJUnit4ClassRunner
with parameters support. Parameters can be
injected via constructor or into annotated fields.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static enum
private class
private class
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected Statement
classBlock
(RunNotifier notifier) Constructs aStatement
to run all of the tests in the test class.Returns a new fixture for running a test.private Object
private Object
private boolean
private List
<FrameworkField> protected String
getName()
Returns a name used to describe this Runnerprotected Annotation[]
protected String
testName
(FrameworkMethod method) Returns the name that describesmethod
forDescription
s.protected void
validateConstructor
(List<Throwable> errors) Adds toerrors
if the test class has more than one constructor, or if the constructor takes parameters.protected void
validateFields
(List<Throwable> errors) private Statement
withAfterParams
(Statement statement) private Statement
withBeforeParams
(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
-
Field Details
-
parameters
-
name
-
-
Constructor Details
-
BlockJUnit4ClassRunnerWithParameters
- Throws:
InitializationError
-
-
Method Details
-
createTest
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 classBlockJUnit4ClassRunner
- Throws:
Exception
-
createTestUsingConstructorInjection
- Throws:
Exception
-
createTestUsingFieldInjection
- Throws:
Exception
-
getName
Description copied from class:ParentRunner
Returns a name used to describe this Runner- Overrides:
getName
in classParentRunner<FrameworkMethod>
-
testName
Description copied from class:BlockJUnit4ClassRunner
Returns the name that describesmethod
forDescription
s. Default implementation is the method's name- Overrides:
testName
in classBlockJUnit4ClassRunner
-
validateConstructor
Description copied from class:BlockJUnit4ClassRunner
Adds toerrors
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 classBlockJUnit4ClassRunner
-
validateFields
- Overrides:
validateFields
in classBlockJUnit4ClassRunner
-
classBlock
Description copied from class:ParentRunner
Constructs aStatement
to 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
ClassRule
s on the test-class and superclasses. - Run all non-overridden
@BeforeClass
methods 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
@AfterClass
methods 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:
classBlock
in classParentRunner<FrameworkMethod>
- Returns:
Statement
- Determine the children to be run using
-
withBeforeParams
-
withAfterParams
-
getRunnerAnnotations
- Overrides:
getRunnerAnnotations
in classParentRunner<FrameworkMethod>
- Returns:
- the annotations that should be attached to this runner's description.
-
getAnnotatedFieldsByParameter
-
getInjectionType
-
fieldsAreAnnotated
private boolean fieldsAreAnnotated()
-