Package net.sf.eBus.test
Class OrderedRunner
- java.lang.Object
-
- org.junit.runner.Runner
-
- org.junit.runners.ParentRunner<org.junit.runners.model.FrameworkMethod>
-
- org.junit.runners.BlockJUnit4ClassRunner
-
- net.sf.eBus.test.OrderedRunner
-
- All Implemented Interfaces:
org.junit.runner.Describable,org.junit.runner.manipulation.Filterable,org.junit.runner.manipulation.Sortable
public class OrderedRunner extends org.junit.runners.BlockJUnit4ClassRunnerThis class extendsorg.junit.runners.BlockJUnit4ClassRunnerand overrides thecomputeTestMethods()method to guarantee that test methods are run in a user-defined order using theTestIndexannotation. While JUnit discourages test method dependencies because increases test maintenance difficultly, breaking a complex test down to a series of simple, dependent test methods is necessary at times.An example using this class runner:
@RunWith(OrderedRunner.class) public final class MyTest { @Test @TestIndex(index=0) public void test0() { ... } @Test @TestIndex(index=1) public void test1 { ... } }Note: this is not meant to replace
org.junit.runner.manipulation.Sortableinterface since that interface should not be used to cope with test method dependencies (as per the JUnit documentation).- Author:
- Charles Rapp
-
-
Constructor Summary
Constructors Constructor Description OrderedRunner(Class<?> clazz)Creates a new OrderedRunner instance for the given test class.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected List<org.junit.runners.model.FrameworkMethod>computeTestMethods()Returns the test methods list sorted according to theirtest indexvalues.-
Methods inherited from class org.junit.runners.BlockJUnit4ClassRunner
collectInitializationErrors, createTest, describeChild, getChildren, getTestRules, isIgnored, methodBlock, methodInvoker, possiblyExpectingExceptions, rules, runChild, testName, validateConstructor, validateFields, validateInstanceMethods, validateNoNonStaticInnerClass, validateOnlyOneConstructor, validateTestMethods, validateZeroArgConstructor, withAfters, withBefores, withPotentialTimeout
-
-
-
-
Constructor Detail
-
OrderedRunner
public OrderedRunner(Class<?> clazz) throws org.junit.runners.model.InitializationError
Creates a new OrderedRunner instance for the given test class.- Parameters:
clazz- the Java class containing the test methods.- Throws:
org.junit.runners.model.InitializationError- if this constructor fails.
-
-
Method Detail
-
computeTestMethods
protected List<org.junit.runners.model.FrameworkMethod> computeTestMethods()
Returns the test methods list sorted according to theirtest indexvalues.- Overrides:
computeTestMethodsin classorg.junit.runners.BlockJUnit4ClassRunner- Returns:
- the sorted test method list.
-
-