|
||||||||||
| 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 TestCases and TestSuites
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,
Serialized Form| Field Summary | |
|---|---|
static Description |
EMPTY
Describes a Runner which runs no tests |
static Description |
TEST_MECHANISM
Describes a step in the test-running mechanism that goes so wrong no other description can be used (for example, an exception thrown from a Runner's constructor |
| Method Summary | ||
|---|---|---|
void |
addChild(Description description)
Add Description as a child of the receiver. |
|
Description |
childlessCopy()
|
|
static Description |
createSuiteDescription(Class<?> testClass)
Create a Description named after testClass |
|
static Description |
createSuiteDescription(Class<?> testClass,
Annotation... annotations)
Create a Description named after testClass |
|
static Description |
createSuiteDescription(String name,
Annotation... annotations)
Create a Description named name. |
|
static Description |
createSuiteDescription(String name,
Serializable uniqueId,
Annotation... annotations)
Create a Description named name. |
|
static Description |
createTestDescription(Class<?> clazz,
String name)
Create a Description of a single test named name in the class clazz. |
|
static Description |
createTestDescription(Class<?> clazz,
String name,
Annotation... annotations)
Create a Description of a single test named name in the class clazz. |
|
static Description |
createTestDescription(String className,
String name,
Annotation... annotations)
Create a Description of a single test named name in the 'class' named
className. |
|
static Description |
createTestDescription(String className,
String name,
Serializable uniqueId)
Create a Description of a single test named name in the class clazz. |
|
boolean |
equals(Object obj)
|
|
|
getAnnotation(Class<T> annotationType)
|
|
Collection<Annotation> |
getAnnotations()
|
|
ArrayList<Description> |
getChildren()
Gets the copy of the children of this Description. |
|
String |
getClassName()
|
|
String |
getDisplayName()
|
|
String |
getMethodName()
|
|
Class<?> |
getTestClass()
|
|
int |
hashCode()
|
|
boolean |
isEmpty()
|
|
boolean |
isSuite()
|
|
boolean |
isTest()
|
|
int |
testCount()
|
|
String |
toString()
|
|
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final Description EMPTY
public static final Description TEST_MECHANISM
| Method Detail |
|---|
public static Description createSuiteDescription(String name,
Annotation... annotations)
Description named name.
Generally, you will add children to this Description.
name - the name of the Descriptionannotations - meta-data about the test, for downstream interpreters
Description named name
public static Description createSuiteDescription(String name,
Serializable uniqueId,
Annotation... annotations)
Description named name.
Generally, you will add children to this Description.
name - the name of the DescriptionuniqueId - an arbitrary object used to define uniqueness (in equals(Object)annotations - meta-data about the test, for downstream interpreters
Description named name
public static Description createTestDescription(String className,
String name,
Annotation... annotations)
Description of a single test named name in the 'class' named
className. Generally, this will be a leaf Description. This method is a better choice
than createTestDescription(Class, String, Annotation...) for test runners whose test cases are not
defined in an actual Java Class.
className - the class name of the testname - the name of the test (a method name for test annotated with Test)annotations - meta-data about the test, for downstream interpreters
Description named name
public static Description createTestDescription(Class<?> clazz,
String name,
Annotation... annotations)
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)annotations - meta-data about the test, for downstream interpreters
Description named name
public static Description createTestDescription(Class<?> clazz,
String name)
Description of a single test named name in the class clazz.
Generally, this will be a leaf Description.
(This remains for binary compatibility with clients of JUnit 4.3)
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 createTestDescription(String className,
String name,
Serializable uniqueId)
Description of a single test named name in the class clazz.
Generally, this will be a leaf Description.
name - the name of the test (a method name for test annotated with Test)
Description named namepublic static Description createSuiteDescription(Class<?> testClass)
Description named after testClass
testClass - A Class containing tests
Description of testClass
public static Description createSuiteDescription(Class<?> testClass,
Annotation... annotations)
Description named after testClass
testClass - A not null Class containing testsannotations - meta-data about the test, for downstream interpreters
Description of testClasspublic String getDisplayName()
public void addChild(Description description)
Description as a child of the receiver.
description - the soon-to-be child.public ArrayList<Description> getChildren()
Description.
Returns an empty list if there are no children.
public boolean isSuite()
true if the receiver is a suitepublic boolean isTest()
true if the receiver is an atomic testpublic int testCount()
public int hashCode()
hashCode in class Objectpublic boolean equals(Object obj)
equals in class Objectpublic String toString()
toString in class Objectpublic boolean isEmpty()
public Description childlessCopy()
public <T extends Annotation> T getAnnotation(Class<T> annotationType)
public Collection<Annotation> getAnnotations()
public Class<?> getTestClass()
public String getClassName()
public String getMethodName()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||