org.junit.runners.model
Class TestClass

java.lang.Object
  extended by org.junit.runners.model.TestClass

public class TestClass
extends Object

Wraps a class to be run, providing method validation and annotation searching

Since:
4.5

Constructor Summary
TestClass(Class<?> klass)
          Creates a TestClass wrapping klass.
 
Method Summary
 List<FrameworkField> getAnnotatedFields(Class<? extends Annotation> annotationClass)
          Returns, efficiently, all the non-overridden fields in this class and its superclasses that are annotated with annotationClass.
<T> List<T>
getAnnotatedFieldValues(Object test, Class<? extends Annotation> annotationClass, Class<T> valueClass)
           
 List<FrameworkMethod> getAnnotatedMethods(Class<? extends Annotation> annotationClass)
          Returns, efficiently, all the non-overridden methods in this class and its superclasses that are annotated with annotationClass.
<T> List<T>
getAnnotatedMethodValues(Object test, Class<? extends Annotation> annotationClass, Class<T> valueClass)
           
 Annotation[] getAnnotations()
          Returns the annotations on this class
 Class<?> getJavaClass()
          Returns the underlying Java class.
 String getName()
          Returns the class's name.
 Constructor<?> getOnlyConstructor()
          Returns the only public constructor in the class, or throws an AssertionError if there are more or less than one.
 boolean isANonStaticInnerClass()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TestClass

public TestClass(Class<?> klass)
Creates a TestClass wrapping klass. Each time this constructor executes, the class is scanned for annotations, which can be an expensive process (we hope in future JDK's it will not be.) Therefore, try to share instances of TestClass where possible.

Method Detail

getAnnotatedMethods

public List<FrameworkMethod> getAnnotatedMethods(Class<? extends Annotation> annotationClass)
Returns, efficiently, all the non-overridden methods in this class and its superclasses that are annotated with annotationClass.


getAnnotatedFields

public List<FrameworkField> getAnnotatedFields(Class<? extends Annotation> annotationClass)
Returns, efficiently, all the non-overridden fields in this class and its superclasses that are annotated with annotationClass.


getJavaClass

public Class<?> getJavaClass()
Returns the underlying Java class.


getName

public String getName()
Returns the class's name.


getOnlyConstructor

public Constructor<?> getOnlyConstructor()
Returns the only public constructor in the class, or throws an AssertionError if there are more or less than one.


getAnnotations

public Annotation[] getAnnotations()
Returns the annotations on this class


getAnnotatedFieldValues

public <T> List<T> getAnnotatedFieldValues(Object test,
                                           Class<? extends Annotation> annotationClass,
                                           Class<T> valueClass)

getAnnotatedMethodValues

public <T> List<T> getAnnotatedMethodValues(Object test,
                                            Class<? extends Annotation> annotationClass,
                                            Class<T> valueClass)

isANonStaticInnerClass

public boolean isANonStaticInnerClass()