public class OrderedRunner
extends org.junit.runners.BlockJUnit4ClassRunner
org.junit.runners.BlockJUnit4ClassRunner and overrides
the computeTestMethods() method to guarantee that
test methods are run in a user-defined order using the
TestIndex annotation. 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.Sortable interface since
that interface should not be used to cope with test method
dependencies (as per the JUnit documentation).
| Constructor and Description |
|---|
OrderedRunner(Class<?> clazz)
Creates a new OrderedRunner instance for the given test
class.
|
| Modifier and Type | Method and Description |
|---|---|
protected List<org.junit.runners.model.FrameworkMethod> |
computeTestMethods()
Returns the test methods list sorted according to their
test index values. |
collectInitializationErrors, createTest, describeChild, getChildren, getTestRules, isIgnored, methodBlock, methodInvoker, possiblyExpectingExceptions, rules, runChild, testName, validateConstructor, validateFields, validateInstanceMethods, validateNoNonStaticInnerClass, validateOnlyOneConstructor, validateTestMethods, validateZeroArgConstructor, withAfters, withBefores, withPotentialTimeoutpublic OrderedRunner(Class<?> clazz) throws org.junit.runners.model.InitializationError
clazz - the Java class containing the test methods.org.junit.runners.model.InitializationError - if this constructor fails.protected List<org.junit.runners.model.FrameworkMethod> computeTestMethods()
test index values.computeTestMethods in class org.junit.runners.BlockJUnit4ClassRunnerCopyright © 2019. All rights reserved.