public class BlockJUnit4ClassRunnerWithParameters extends BlockJUnit4ClassRunner
BlockJUnit4ClassRunner
with parameters support. Parameters can be
injected via constructor or into annotated fields.Modifier and Type | Class and Description |
---|---|
private static class |
BlockJUnit4ClassRunnerWithParameters.InjectionType |
private class |
BlockJUnit4ClassRunnerWithParameters.RunAfterParams |
private class |
BlockJUnit4ClassRunnerWithParameters.RunBeforeParams |
Modifier and Type | Field and Description |
---|---|
private java.lang.String |
name |
private java.lang.Object[] |
parameters |
Constructor and Description |
---|
BlockJUnit4ClassRunnerWithParameters(TestWithParameters test) |
Modifier and Type | Method and Description |
---|---|
protected Statement |
classBlock(RunNotifier notifier)
Constructs a
Statement to run all of the tests in the test class. |
java.lang.Object |
createTest()
Returns a new fixture for running a test.
|
private java.lang.Object |
createTestUsingConstructorInjection() |
private java.lang.Object |
createTestUsingFieldInjection() |
private boolean |
fieldsAreAnnotated() |
private java.util.List<FrameworkField> |
getAnnotatedFieldsByParameter() |
private BlockJUnit4ClassRunnerWithParameters.InjectionType |
getInjectionType() |
protected java.lang.String |
getName()
Returns a name used to describe this Runner
|
protected java.lang.annotation.Annotation[] |
getRunnerAnnotations() |
protected java.lang.String |
testName(FrameworkMethod method)
Returns the name that describes
method for Description s. |
protected void |
validateConstructor(java.util.List<java.lang.Throwable> errors)
Adds to
errors if the test class has more than one constructor,
or if the constructor takes parameters. |
protected void |
validateFields(java.util.List<java.lang.Throwable> errors) |
private Statement |
withAfterParams(Statement statement) |
private Statement |
withBeforeParams(Statement statement) |
collectInitializationErrors, computeTestMethods, createTest, describeChild, getChildren, getTestRules, isIgnored, methodBlock, methodInvoker, possiblyExpectingExceptions, rules, runChild, validateInstanceMethods, validateNoNonStaticInnerClass, validateOnlyOneConstructor, validateTestMethods, validateZeroArgConstructor, withAfters, withBefores, withPotentialTimeout
childrenInvoker, classRules, createTestClass, filter, getDescription, getTestClass, order, run, runLeaf, setScheduler, sort, validatePublicVoidNoArgMethods, withAfterClasses, withBeforeClasses, withInterruptIsolation
private final java.lang.Object[] parameters
private final java.lang.String name
public BlockJUnit4ClassRunnerWithParameters(TestWithParameters test) throws InitializationError
InitializationError
public java.lang.Object createTest() throws java.lang.Exception
BlockJUnit4ClassRunner
createTest
in class BlockJUnit4ClassRunner
java.lang.Exception
private java.lang.Object createTestUsingConstructorInjection() throws java.lang.Exception
java.lang.Exception
private java.lang.Object createTestUsingFieldInjection() throws java.lang.Exception
java.lang.Exception
protected java.lang.String getName()
ParentRunner
getName
in class ParentRunner<FrameworkMethod>
protected java.lang.String testName(FrameworkMethod method)
BlockJUnit4ClassRunner
method
for Description
s.
Default implementation is the method's nametestName
in class BlockJUnit4ClassRunner
protected void validateConstructor(java.util.List<java.lang.Throwable> errors)
BlockJUnit4ClassRunner
errors
if the test class has more than one constructor,
or if the constructor takes parameters. Override if a subclass requires
different validation rules.validateConstructor
in class BlockJUnit4ClassRunner
protected void validateFields(java.util.List<java.lang.Throwable> errors)
validateFields
in class BlockJUnit4ClassRunner
protected Statement classBlock(RunNotifier notifier)
ParentRunner
Statement
to run all of the tests in the test class.
Override to add pre-/post-processing. Here is an outline of the
implementation:
ParentRunner.getChildren()
(subject to any imposed filter and sort).ClassRule
s on the test-class and superclasses.@BeforeClass
methods on the test-class
and superclasses; if any throws an Exception, stop execution and pass the
exception on.@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
.classBlock
in class ParentRunner<FrameworkMethod>
Statement
protected java.lang.annotation.Annotation[] getRunnerAnnotations()
getRunnerAnnotations
in class ParentRunner<FrameworkMethod>
private java.util.List<FrameworkField> getAnnotatedFieldsByParameter()
private BlockJUnit4ClassRunnerWithParameters.InjectionType getInjectionType()
private boolean fieldsAreAnnotated()