|
|
|||||||||
| 上一个类 下一个类 | 框架 无框架 | ||||||||
| 摘要: 嵌套 | 字段 | 构造器 | 方法 | 详细信息: 字段 | 构造器 | 方法 | ||||||||
org.junit.runners Class ParentRunner<T>
java.lang.Objectorg.junit.runner.Runner
org.junit.runners.ParentRunner<T>
- 所有已实现接口:
- Describable, Filterable, Sortable
- 已知直接子类:
- BlockJUnit4ClassRunner, Suite
public abstract class ParentRunner<T>
- extends Runner
- implements Filterable, Sortable
Provides most of the functionality specific to a Runner that implements a
"parent node" in the test tree, with children defined by objects of some data
type T. (For BlockJUnit4ClassRunner, T is
Method . For Suite, T is Class.) Subclasses
must implement finding the children of the node, describing each child, and
running each child. ParentRunner will filter and sort children, handle
@BeforeClass and @AfterClass methods, create a composite
Description, and run children sequentially.
| 构造器摘要 | |
|---|---|
protected |
ParentRunner(Class<?> testClass)
Constructs a new ParentRunner that will run @TestClass |
| 方法摘要 | |
|---|---|
protected org.junit.runners.model.Statement |
childrenInvoker(RunNotifier notifier)
Returns a Statement: Call runChild(Object, RunNotifier)
on each object returned by getChildren() (subject to any imposed
filter and sort) |
protected org.junit.runners.model.Statement |
classBlock(RunNotifier notifier)
Constructs a Statement to run all of the tests in the test class. |
protected void |
collectInitializationErrors(List<Throwable> errors)
Adds to errors a throwable for each problem noted with the test class (available from getTestClass()). |
protected abstract Description |
describeChild(T child)
Returns a Description for child, which can be assumed to
be an element of the list returned by getChildren() |
void |
filter(Filter filter)
Remove tests that don't pass the parameter filter. |
protected abstract List<T> |
getChildren()
Returns a list of objects that define the children of this Runner. |
Description |
getDescription()
|
protected String |
getName()
Returns a name used to describe this Runner |
org.junit.runners.model.TestClass |
getTestClass()
Returns a TestClass object wrapping the class to be executed. |
void |
run(RunNotifier notifier)
Run the tests for this runner. |
protected abstract void |
runChild(T child,
RunNotifier notifier)
Runs the test corresponding to child, which can be assumed to be
an element of the list returned by getChildren(). |
void |
setScheduler(org.junit.runners.model.RunnerScheduler scheduler)
Sets a scheduler that determines the order and parallelization of children. |
void |
sort(Sorter sorter)
Sorts the tests using sorter |
protected void |
validatePublicVoidNoArgMethods(Class<? extends Annotation> annotation,
boolean isStatic,
List<Throwable> errors)
Adds to errors if any method in this class is annotated with
annotation, but:
is not public, or
takes parameters, or
returns something other than void, or
is static (given isStatic is false), or
is not static (given isStatic is true). |
protected org.junit.runners.model.Statement |
withAfterClasses(org.junit.runners.model.Statement statement)
Returns a Statement: run all non-overridden @AfterClass methods on this class
and superclasses before executing statement; all AfterClass methods are
always executed: exceptions thrown by previous steps are combined, if
necessary, with exceptions from AfterClass methods into a
MultipleFailureException. |
protected org.junit.runners.model.Statement |
withBeforeClasses(org.junit.runners.model.Statement statement)
Returns a Statement: run all non-overridden @BeforeClass methods on this class
and superclasses before executing statement; if any throws an
Exception, stop execution and pass the exception on. |
| 类方法继承: org.junit.runner.Runner |
|---|
testCount |
| 类方法继承: java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| 构造器详细信息 |
|---|
ParentRunner
protected ParentRunner(Class<?> testClass) throws org.junit.runners.model.InitializationError
- Constructs a new
ParentRunnerthat will run@TestClass- 抛出异常:
org.junit.runners.model.InitializationError
| 方法详细信息 |
|---|
getChildren
protected abstract List<T> getChildren()
- Returns a list of objects that define the children of this Runner.
describeChild
protected abstract Description describeChild(T child)
- Returns a
Descriptionforchild, which can be assumed to be an element of the list returned bygetChildren()
runChild
protected abstract void runChild(T child, RunNotifier notifier)
- Runs the test corresponding to
child, which can be assumed to be an element of the list returned bygetChildren(). Subclasses are responsible for making sure that relevant test events are reported throughnotifier
collectInitializationErrors
protected void collectInitializationErrors(List<Throwable> errors)
- Adds to
errorsa throwable for each problem noted with the test class (available fromgetTestClass()). Default implementation adds an error for each method annotated with@BeforeClassor@AfterClassthat is notpublic static voidwith no arguments.
validatePublicVoidNoArgMethods
protected void validatePublicVoidNoArgMethods(Class<? extends Annotation> annotation, boolean isStatic, List<Throwable> errors)
- Adds to
errorsif any method in this class is annotated withannotation, but:- is not public, or
- takes parameters, or
- returns something other than void, or
- is static (given
isStatic is false), or - is not static (given
isStatic is true).
classBlock
protected org.junit.runners.model.Statement classBlock(RunNotifier notifier)
- Constructs a
Statementto run all of the tests in the test class. Override to add pre-/post-processing. Here is an outline of the implementation:- Call
runChild(Object, RunNotifier)on each object returned bygetChildren()(subject to any imposed filter and sort). - ALWAYS run all non-overridden
@BeforeClassmethods on this class and superclasses before the previous step; if any throws an Exception, stop execution and pass the exception on. - ALWAYS run all non-overridden
@AfterClassmethods on this class and superclasses before any of the previous steps; all AfterClass methods are always executed: exceptions thrown by previous steps are combined, if necessary, with exceptions from AfterClass methods into aMultipleFailureException.
- Call
- 参数:
notifier-- 返回:
Statement
withBeforeClasses
protected org.junit.runners.model.Statement withBeforeClasses(org.junit.runners.model.Statement statement)
- Returns a
Statement: run all non-overridden@BeforeClassmethods on this class and superclasses before executingstatement; if any throws an Exception, stop execution and pass the exception on.
withAfterClasses
protected org.junit.runners.model.Statement withAfterClasses(org.junit.runners.model.Statement statement)
- Returns a
Statement: run all non-overridden@AfterClassmethods on this class and superclasses before executingstatement; all AfterClass methods are always executed: exceptions thrown by previous steps are combined, if necessary, with exceptions from AfterClass methods into aMultipleFailureException.
childrenInvoker
protected org.junit.runners.model.Statement childrenInvoker(RunNotifier notifier)
- Returns a
Statement: CallrunChild(Object, RunNotifier)on each object returned bygetChildren()(subject to any imposed filter and sort)
getName
protected String getName()
- Returns a name used to describe this Runner
getTestClass
public final org.junit.runners.model.TestClass getTestClass()
- Returns a
TestClassobject wrapping the class to be executed.
getDescription
public Description getDescription()
- 规范说明:
getDescriptionin interfaceDescribable- 规范说明:
getDescriptionin classRunner
- 返回:
- a
Descriptionshowing the tests to be run by the receiver
run
public void run(RunNotifier notifier)
- Description copied from class:
Runner - Run the tests for this runner.
- 参数:
notifier- will be notified of events while tests are being run--tests being started, finishing, and failing
filter
public void filter(Filter filter) throws NoTestsRemainException
- Description copied from interface:
Filterable - Remove tests that don't pass the parameter
filter. - 规范说明:
filterin interfaceFilterable
- 参数:
filter- theFilterto apply- 抛出异常:
NoTestsRemainException- if all tests are filtered out
sort
public void sort(Sorter sorter)
- Description copied from interface:
Sortable - Sorts the tests using
sorter - 参数:
sorter- theSorterto use for sorting the tests
setScheduler
public void setScheduler(org.junit.runners.model.RunnerScheduler scheduler)
- Sets a scheduler that determines the order and parallelization
of children. Highly experimental feature that may change.
|
|
|||||||||
| 上一个类 下一个类 | 框架 无框架 | ||||||||
| 摘要: 嵌套 | 字段 | 构造器 | 方法 | 详细信息: 字段 | 构造器 | 方法 | ||||||||
