public class Theories extends BlockJUnit4ClassRunner
Modifier and Type | Class and Description |
---|---|
static class |
Theories.TheoryAnchor |
Modifier and Type | Method and Description |
---|---|
protected void |
collectInitializationErrors(List<Throwable> errors)
Adds to
errors a throwable for each problem noted with the test class (available from ParentRunner.getTestClass() ). |
protected List<FrameworkMethod> |
computeTestMethods()
Returns the methods that run tests.
|
Statement |
methodBlock(FrameworkMethod method)
Returns a Statement that, when executed, either returns normally if
method passes, or throws an exception if method fails. |
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 |
validateTestMethods(List<Throwable> errors)
Adds to
errors for each method annotated with @Test that
is not a public, void instance method with no arguments. |
createTest, describeChild, getChildren, getTestRules, methodInvoker, possiblyExpectingExceptions, rules, runChild, testName, validateFields, validateInstanceMethods, validateNoNonStaticInnerClass, validateOnlyOneConstructor, validateZeroArgConstructor, withAfters, withBefores, withPotentialTimeout
childrenInvoker, classBlock, classRules, filter, getDescription, getName, getRunnerAnnotations, getTestClass, run, runLeaf, setScheduler, sort, validatePublicVoidNoArgMethods, withAfterClasses, withBeforeClasses
public Theories(Class<?> klass) throws InitializationError
InitializationError
protected void collectInitializationErrors(List<Throwable> errors)
ParentRunner
errors
a throwable for each problem noted with the test class (available from ParentRunner.getTestClass()
).
Default implementation adds an error for each method annotated with
@BeforeClass
or @AfterClass
that is not
public static void
with no arguments.collectInitializationErrors
in class BlockJUnit4ClassRunner
protected void validateConstructor(List<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 validateTestMethods(List<Throwable> errors)
BlockJUnit4ClassRunner
errors
for each method annotated with @Test
that
is not a public, void instance method with no arguments.validateTestMethods
in class BlockJUnit4ClassRunner
protected List<FrameworkMethod> computeTestMethods()
BlockJUnit4ClassRunner
@Test
on this class and superclasses that
are not overridden.computeTestMethods
in class BlockJUnit4ClassRunner
public Statement methodBlock(FrameworkMethod method)
BlockJUnit4ClassRunner
method
passes, or throws an exception if method
fails.
Here is an outline of the default implementation:
method
on the result of createTest()
, and
throw any exceptions thrown by either operation.
method
's @Test
annotation has the expecting
attribute, return normally only if the previous step threw an
exception of the correct type, and throw an exception otherwise.
method
's @Test
annotation has the timeout
attribute, throw an exception if the previous step takes more
than the specified number of milliseconds.
@Before
methods on this class
and superclasses before any of the previous steps; if any throws an
Exception, stop execution and pass the exception on.
@After
methods on this class
and superclasses after any of the previous steps; all After methods are
always executed: exceptions thrown by previous steps are combined, if
necessary, with exceptions from After methods into a
MultipleFailureException
.
@Rule
fields to modify the execution of the
above steps. A Rule
may prevent all execution of the above steps,
or add additional behavior before and after, or modify thrown exceptions.
For more information, see TestRule
methodBlock
in class BlockJUnit4ClassRunner