Package org.junit.runners.model
Class TestClass
- java.lang.Object
-
- org.junit.runners.model.TestClass
-
public class TestClass extends java.lang.Object
Wraps a class to be run, providing method validation and annotation searching- Since:
- 4.5
-
-
Constructor Summary
Constructors Constructor Description TestClass(java.lang.Class<?> klass)
Creates aTestClass
wrappingklass
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.List<FrameworkField>
getAnnotatedFields(java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass)
Returns, efficiently, all the non-overridden fields in this class and its superclasses that are annotated withannotationClass
.<T> java.util.List<T>
getAnnotatedFieldValues(java.lang.Object test, java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass, java.lang.Class<T> valueClass)
java.util.List<FrameworkMethod>
getAnnotatedMethods(java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass)
Returns, efficiently, all the non-overridden methods in this class and its superclasses that are annotated withannotationClass
.<T> java.util.List<T>
getAnnotatedMethodValues(java.lang.Object test, java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass, java.lang.Class<T> valueClass)
java.lang.annotation.Annotation[]
getAnnotations()
Returns the annotations on this classjava.lang.Class<?>
getJavaClass()
Returns the underlying Java class.java.lang.String
getName()
Returns the class's name.java.lang.reflect.Constructor<?>
getOnlyConstructor()
Returns the only public constructor in the class, or throws anAssertionError
if there are more or less than one.boolean
isANonStaticInnerClass()
-
-
-
Constructor Detail
-
TestClass
public TestClass(java.lang.Class<?> klass)
Creates aTestClass
wrappingklass
. 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 ofTestClass
where possible.
-
-
Method Detail
-
getAnnotatedMethods
public java.util.List<FrameworkMethod> getAnnotatedMethods(java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass)
Returns, efficiently, all the non-overridden methods in this class and its superclasses that are annotated withannotationClass
.
-
getAnnotatedFields
public java.util.List<FrameworkField> getAnnotatedFields(java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass)
Returns, efficiently, all the non-overridden fields in this class and its superclasses that are annotated withannotationClass
.
-
getJavaClass
public java.lang.Class<?> getJavaClass()
Returns the underlying Java class.
-
getName
public java.lang.String getName()
Returns the class's name.
-
getOnlyConstructor
public java.lang.reflect.Constructor<?> getOnlyConstructor()
Returns the only public constructor in the class, or throws anAssertionError
if there are more or less than one.
-
getAnnotations
public java.lang.annotation.Annotation[] getAnnotations()
Returns the annotations on this class
-
getAnnotatedFieldValues
public <T> java.util.List<T> getAnnotatedFieldValues(java.lang.Object test, java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass, java.lang.Class<T> valueClass)
-
getAnnotatedMethodValues
public <T> java.util.List<T> getAnnotatedMethodValues(java.lang.Object test, java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass, java.lang.Class<T> valueClass)
-
isANonStaticInnerClass
public boolean isANonStaticInnerClass()
-
-