|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.junit.runner.Description
public class Description
A Description
describes a test which is to be run or has been run. Descriptions
can
be atomic (a single test) or compound (containing children tests). Descriptions
are used
to provide feedback about the tests that are about to run (for example, the tree view
visible in many IDEs) or tests that have been run (for example, the failures view).
Descriptions
are implemented as a single class rather than a Composite because
they are entirely informational. They contain no logic aside from counting their tests.
In the past, we used the raw junit.framework.TestCase
s and junit.framework.TestSuite
s
to display the tree of tests. This was no longer viable in JUnit 4 because atomic tests no longer have a superclass below Object
.
We needed a way to pass a class and name together. Description emerged from this.
Request
,
Runner
Field Summary | |
---|---|
static Description |
TEST_MECHANISM
|
Method Summary | |
---|---|
void |
addChild(Description description)
Add description as a child of the receiver. |
static Description |
createSuiteDescription(java.lang.Class<?> testClass)
Create a generic Description that says there are tests in testClass . |
static Description |
createSuiteDescription(java.lang.String name)
Create a Description named name . |
static Description |
createTestDescription(java.lang.Class clazz,
java.lang.String name)
Create a Description of a single test named name in the class clazz . |
boolean |
equals(java.lang.Object obj)
|
java.util.ArrayList<Description> |
getChildren()
|
java.lang.String |
getDisplayName()
|
int |
hashCode()
|
boolean |
isSuite()
|
boolean |
isTest()
|
int |
testCount()
|
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static Description TEST_MECHANISM
Method Detail |
---|
public static Description createSuiteDescription(java.lang.String name)
Description
named name
.
Generally, you will add children to this Description
.
name
- The name of the Description
Description
named name
public static Description createTestDescription(java.lang.Class clazz, java.lang.String name)
Description
of a single test named name
in the class clazz
.
Generally, this will be a leaf Description
.
clazz
- The class of the testname
- The name of the test (a method name for test annotated with @Test
)
Description
named name
public static Description createSuiteDescription(java.lang.Class<?> testClass)
Description
that says there are tests in testClass
.
This is used as a last resort when you cannot precisely describe the individual tests in the class.
testClass
- A Class
containing tests
Description
of testClass
public java.lang.String getDisplayName()
public void addChild(Description description)
description
as a child of the receiver.
description
- The soon-to-be child.public java.util.ArrayList<Description> getChildren()
public boolean isSuite()
public boolean isTest()
public int testCount()
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |