Package org.junit.experimental.theories
Class Theories
- java.lang.Object
-
- org.junit.runner.Runner
-
- org.junit.runners.ParentRunner<FrameworkMethod>
-
- org.junit.runners.BlockJUnit4ClassRunner
-
- org.junit.experimental.theories.Theories
-
- All Implemented Interfaces:
Describable,Filterable,Sortable
public class Theories extends BlockJUnit4ClassRunner
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classTheories.TheoryAnchor
-
Constructor Summary
Constructors Constructor Description Theories(java.lang.Class<?> klass)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcollectInitializationErrors(java.util.List<java.lang.Throwable> errors)Adds toerrorsa throwable for each problem noted with the test class (available fromParentRunner.getTestClass()).protected java.util.List<FrameworkMethod>computeTestMethods()Returns the methods that run tests.StatementmethodBlock(FrameworkMethod method)Returns a Statement that, when executed, either returns normally ifmethodpasses, or throws an exception ifmethodfails.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 voidvalidateTestMethods(java.util.List<java.lang.Throwable> errors)Adds toerrorsfor each method annotated with@Testthat is not a public, void instance method with no arguments.-
Methods inherited from class org.junit.runners.BlockJUnit4ClassRunner
createTest, describeChild, getChildren, getTestRules, methodInvoker, possiblyExpectingExceptions, rules, runChild, testName, validateFields, validateInstanceMethods, validateNoNonStaticInnerClass, validateOnlyOneConstructor, validateZeroArgConstructor, withAfters, withBefores, withPotentialTimeout
-
Methods inherited from class org.junit.runners.ParentRunner
childrenInvoker, classBlock, classRules, filter, getDescription, getName, getRunnerAnnotations, getTestClass, run, runLeaf, setScheduler, sort, validatePublicVoidNoArgMethods, withAfterClasses, withBeforeClasses
-
-
-
-
Constructor Detail
-
Theories
public Theories(java.lang.Class<?> klass) throws InitializationError- Throws:
InitializationError
-
-
Method Detail
-
collectInitializationErrors
protected void collectInitializationErrors(java.util.List<java.lang.Throwable> errors)
Description copied from class:ParentRunnerAdds toerrorsa throwable for each problem noted with the test class (available fromParentRunner.getTestClass()). Default implementation adds an error for each method annotated with@BeforeClassor@AfterClassthat is notpublic static voidwith no arguments.- Overrides:
collectInitializationErrorsin 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
-
validateTestMethods
protected void validateTestMethods(java.util.List<java.lang.Throwable> errors)
Description copied from class:BlockJUnit4ClassRunnerAdds toerrorsfor each method annotated with@Testthat is not a public, void instance method with no arguments.- Overrides:
validateTestMethodsin classBlockJUnit4ClassRunner
-
computeTestMethods
protected java.util.List<FrameworkMethod> computeTestMethods()
Description copied from class:BlockJUnit4ClassRunnerReturns the methods that run tests. Default implementation returns all methods annotated with@Teston this class and superclasses that are not overridden.- Overrides:
computeTestMethodsin classBlockJUnit4ClassRunner
-
methodBlock
public Statement methodBlock(FrameworkMethod method)
Description copied from class:BlockJUnit4ClassRunnerReturns a Statement that, when executed, either returns normally ifmethodpasses, or throws an exception ifmethodfails. Here is an outline of the default implementation:- Invoke
methodon the result ofcreateTest(), and throw any exceptions thrown by either operation. - HOWEVER, if
method's@Testannotation has theexpectingattribute, return normally only if the previous step threw an exception of the correct type, and throw an exception otherwise. - HOWEVER, if
method's@Testannotation has thetimeoutattribute, throw an exception if the previous step takes more than the specified number of milliseconds. - ALWAYS run all non-overridden
@Beforemethods on this class and superclasses before any of the previous steps; if any throws an Exception, stop execution and pass the exception on. - ALWAYS run all non-overridden
@Aftermethods 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 aMultipleFailureException. - ALWAYS allow
@Rulefields to modify the execution of the above steps. ARulemay prevent all execution of the above steps, or add additional behavior before and after, or modify thrown exceptions. For more information, seeTestRule
- Overrides:
methodBlockin classBlockJUnit4ClassRunner
- Invoke
-
-