de.bechte.junit.runners.context
Class HierarchicalContextRunner

java.lang.Object
  extended by org.junit.runner.Runner
      extended by de.bechte.junit.runners.context.HierarchicalContextRunner
All Implemented Interfaces:
org.junit.runner.Describable

public class HierarchicalContextRunner
extends org.junit.runner.Runner

The HierarchicalContextRunner allows test classes to have member classes. These member classes are interpreted as context hierarchies, allowing you to group your JUnit tests that use the same preconditions. Please refer to the wiki for a sample and more information: https://github.com/bechte/junit-hierarchicalcontextrunner/wiki


Field Summary
protected  Describer<Class<?>> contextDescriber
           
protected  ChildResolver<Class<?>> contextResolver
           
protected  ChildExecutor<Class<?>> contextRunner
           
protected  Describer<org.junit.runners.model.FrameworkMethod> methodDescriber
           
protected  ChildResolver<org.junit.runners.model.FrameworkMethod> methodResolver
           
protected  ChildExecutor<org.junit.runners.model.FrameworkMethod> methodRunner
           
protected  List<ClassStatementBuilder> statementBuilders
           
protected  StatementExecutor statementExecutor
           
protected  org.junit.runners.model.TestClass testClass
           
 
Constructor Summary
HierarchicalContextRunner(Class<?> testClass)
           
 
Method Summary
 org.junit.runner.Description getDescription()
           
protected  TestClassValidator getValidator()
          Returns a TestClassValidator that validates the TestClass instance after the HierarchicalContextRunner has been created for the corresponding Class.
protected  void initialize()
          Initializes all dependencies for the HierarchicalContextRunner.
 void run(org.junit.runner.notification.RunNotifier notifier)
           
protected  org.junit.runners.model.Statement runChildren(org.junit.runner.Description description, org.junit.runner.notification.RunNotifier notifier)
          This method returns a Statement that is responsible for running all children of the given test class.
 
Methods inherited from class org.junit.runner.Runner
testCount
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

testClass

protected final org.junit.runners.model.TestClass testClass

methodResolver

protected ChildResolver<org.junit.runners.model.FrameworkMethod> methodResolver

methodDescriber

protected Describer<org.junit.runners.model.FrameworkMethod> methodDescriber

methodRunner

protected ChildExecutor<org.junit.runners.model.FrameworkMethod> methodRunner

contextResolver

protected ChildResolver<Class<?>> contextResolver

contextDescriber

protected Describer<Class<?>> contextDescriber

contextRunner

protected ChildExecutor<Class<?>> contextRunner

statementExecutor

protected StatementExecutor statementExecutor

statementBuilders

protected List<ClassStatementBuilder> statementBuilders
Constructor Detail

HierarchicalContextRunner

public HierarchicalContextRunner(Class<?> testClass)
                          throws org.junit.runners.model.InitializationError
Throws:
org.junit.runners.model.InitializationError
Method Detail

getValidator

protected TestClassValidator getValidator()
Returns a TestClassValidator that validates the TestClass instance after the HierarchicalContextRunner has been created for the corresponding Class. To use multiple TestClassValidators, please use the BooleanValidator AND and OR to group your validators. Note: Clients may override this method to add or remove validators.

Returns:
a TestClassValidator

initialize

protected void initialize()
Initializes all dependencies for the HierarchicalContextRunner. Note: Clients may override this method to provide other dependencies.


getDescription

public org.junit.runner.Description getDescription()
Specified by:
getDescription in interface org.junit.runner.Describable
Specified by:
getDescription in class org.junit.runner.Runner

run

public void run(org.junit.runner.notification.RunNotifier notifier)
Specified by:
run in class org.junit.runner.Runner

runChildren

protected org.junit.runners.model.Statement runChildren(org.junit.runner.Description description,
                                                        org.junit.runner.notification.RunNotifier notifier)
This method returns a Statement that is responsible for running all children of the given test class. In order to run more than one Statement, please use the RunAll statement for grouping. Note: Clients may override this method. The statement returned should only be responsible for running the children. Extra work may be registered with the statementBuilders list which is initialized during the call of initialize(). Please register additional payload, e.g. the run of @BeforeClass, @AfterClass or @ClassRule, there. ClassStatementBuilders will be called in the order they are registered.

Parameters:
description - the Description of the class
notifier - the RunNotifier used for this iteration
Returns:
a Statement that runs all children


Copyright © 2015. All rights reserved.