Class ClassSource
- java.lang.Object
-
- org.junit.platform.engine.support.descriptor.ClassSource
-
- All Implemented Interfaces:
Serializable,TestSource
@API(status=STABLE, since="1.0") public class ClassSource extends Object implements TestSource
Class basedTestSourcewith an optional file position.If a Java
Classreference is provided, theClassSourcewill contain thatClassand its class name accordingly. If a class name is provided, theClassSourcewill contain the class name and will only attempt to lazily load theClassifgetJavaClass()is invoked.In this context, Java
Classmeans anything that can be referenced as aClasson the JVM — for example, classes from other JVM languages such Groovy, Scala, etc.- Since:
- 1.0
- See Also:
ClassSelector, Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object o)static ClassSourcefrom(Class<?> javaClass)Create a newClassSourceusing the supplied class.static ClassSourcefrom(Class<?> javaClass, FilePosition filePosition)static ClassSourcefrom(String className)Create a newClassSourceusing the supplied class name.static ClassSourcefrom(String className, FilePosition filePosition)Create a newClassSourceusing the supplied class name and file position.StringgetClassName()Get the class name of this source.Class<?>getJavaClass()Get the Java class of this source.Optional<FilePosition>getPosition()inthashCode()StringtoString()
-
-
-
Method Detail
-
from
public static ClassSource from(String className)
Create a newClassSourceusing the supplied class name.- Parameters:
className- the class name; must not benullor blank
-
from
public static ClassSource from(String className, FilePosition filePosition)
Create a newClassSourceusing the supplied class name and file position.- Parameters:
className- the class name; must not benullor blankfilePosition- the position in the source file; may benull
-
from
public static ClassSource from(Class<?> javaClass)
Create a newClassSourceusing the supplied class.- Parameters:
javaClass- the Java class; must not benull
-
from
public static ClassSource from(Class<?> javaClass, FilePosition filePosition)
- Parameters:
javaClass- the Java class; must not benullfilePosition- the position in the Java source file; may benull
-
getClassName
public final String getClassName()
Get the class name of this source.- See Also:
getJavaClass(),getPosition()
-
getJavaClass
public final Class<?> getJavaClass()
Get the Java class of this source.If the
Classwas not provided, but only the name, this method attempts to lazily load theClassbased on its name and throws aPreconditionViolationExceptionif the class cannot be loaded.- See Also:
getClassName(),getPosition()
-
getPosition
public final Optional<FilePosition> getPosition()
- See Also:
getClassName(),getJavaClass()
-
-