public class

Theories

extends BlockJUnit4ClassRunner
java.lang.Object
   ↳ org.junit.runner.Runner
     ↳ org.junit.runners.ParentRunner<T>
       ↳ org.junit.runners.BlockJUnit4ClassRunner
         ↳ org.junit.experimental.theories.Theories

Summary

Nested Classes
class Theories.TheoryAnchor  
Public Constructors
Theories(Class<?> klass)
Public Methods
Statement methodBlock(FrameworkMethod method)
Returns a Statement that, when executed, either returns normally if method passes, or throws an exception if method fails.
Protected Methods
void collectInitializationErrors(List<Throwable> errors)
Adds to errors a throwable for each problem noted with the test class (available from getTestClass()).
List<FrameworkMethod> computeTestMethods()
Returns the methods that run tests.
void validateConstructor(List<Throwable> errors)
Adds to errors if the test class has more than one constructor, or if the constructor takes parameters.
void validateTestMethods(List<Throwable> errors)
Adds to errors for each method annotated with @Testthat is not a public, void instance method with no arguments.
[Expand]
Inherited Methods
From class org.junit.runners.BlockJUnit4ClassRunner
From class org.junit.runners.ParentRunner
From class org.junit.runner.Runner
From class java.lang.Object
From interface org.junit.runner.Describable
From interface org.junit.runner.manipulation.Filterable
From interface org.junit.runner.manipulation.Sortable

Public Constructors

public Theories (Class<?> klass)

Public Methods

public Statement methodBlock (FrameworkMethod method)

Returns a Statement that, when executed, either returns normally if method passes, or throws an exception if method fails. Here is an outline of the default implementation:

  • Invoke method on the result of createTest(), and throw any exceptions thrown by either operation.
  • HOWEVER, if 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.
  • HOWEVER, if method's @Test annotation has the timeout attribute, throw an exception if the previous step takes more than the specified number of milliseconds.
  • ALWAYS allow @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 MethodRule
  • ALWAYS run all non-overridden @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.
  • ALWAYS run all non-overridden @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.
This can be overridden in subclasses, either by overriding this method, or the implementations creating each sub-statement.

Protected Methods

protected void collectInitializationErrors (List<Throwable> errors)

Adds to errors a throwable for each problem noted with the test class (available from getTestClass()). Default implementation adds an error for each method annotated with @BeforeClass or @AfterClass that is not public static void with no arguments.

protected List<FrameworkMethod> computeTestMethods ()

Returns the methods that run tests. Default implementation returns all methods annotated with @Test on this class and superclasses that are not overridden.

protected void validateConstructor (List<Throwable> errors)

Adds to errors if the test class has more than one constructor, or if the constructor takes parameters. Override if a subclass requires different validation rules.

protected void validateTestMethods (List<Throwable> errors)

Adds to errors for each method annotated with @Testthat is not a public, void instance method with no arguments.