Class DiscoverySelectors
- java.lang.Object
-
- org.junit.platform.engine.discovery.DiscoverySelectors
-
@API(status=STABLE, since="1.0") public final class DiscoverySelectors extends java.lang.Object
Collection ofstatic
factory methods for creatingDiscoverySelectors
.- Since:
- 1.0
- See Also:
ClasspathRootSelector
,ClasspathResourceSelector
,ClassSelector
,MethodSelector
,PackageSelector
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ClassSelector
selectClass(java.lang.Class<?> clazz)
Create aClassSelector
for the suppliedClass
.static ClassSelector
selectClass(java.lang.String className)
Create aClassSelector
for the supplied class name.static ClasspathResourceSelector
selectClasspathResource(java.lang.String classpathResourceName)
Create aClasspathResourceSelector
for the supplied classpath resource name.static java.util.List<ClasspathRootSelector>
selectClasspathRoots(java.util.Set<java.nio.file.Path> classpathRoots)
Create a list ofClasspathRootSelectors
for the supplied classpath roots (directories or JAR files).static DirectorySelector
selectDirectory(java.io.File directory)
Create aDirectorySelector
for the supplied directory.static DirectorySelector
selectDirectory(java.lang.String path)
Create aDirectorySelector
for the supplied directory path.static FileSelector
selectFile(java.io.File file)
Create aFileSelector
for the supplied file.static FileSelector
selectFile(java.lang.String path)
Create aFileSelector
for the supplied file path.static MethodSelector
selectMethod(java.lang.Class<?> javaClass, java.lang.reflect.Method method)
Create aMethodSelector
for the suppliedClass
andMethod
.static MethodSelector
selectMethod(java.lang.Class<?> javaClass, java.lang.String methodName)
Create aMethodSelector
for the suppliedClass
and method name.static MethodSelector
selectMethod(java.lang.Class<?> javaClass, java.lang.String methodName, java.lang.String methodParameterTypes)
Create aMethodSelector
for the suppliedClass
, method name, and method parameter types.static MethodSelector
selectMethod(java.lang.String fullyQualifiedMethodName)
Create aMethodSelector
for the supplied fully qualified method name.static MethodSelector
selectMethod(java.lang.String className, java.lang.String methodName)
Create aMethodSelector
for the supplied class name and method name.static MethodSelector
selectMethod(java.lang.String className, java.lang.String methodName, java.lang.String methodParameterTypes)
Create aMethodSelector
for the supplied class name, method name, and method parameter types.static ModuleSelector
selectModule(java.lang.String moduleName)
Create aModuleSelector
for the supplied module name.static java.util.List<ModuleSelector>
selectModules(java.util.Set<java.lang.String> moduleNames)
Create a list ofModuleSelectors
for the supplied module names.static PackageSelector
selectPackage(java.lang.String packageName)
Create aPackageSelector
for the supplied package name.static UniqueIdSelector
selectUniqueId(java.lang.String uniqueId)
Create aUniqueIdSelector
for the supplied unique ID.static UniqueIdSelector
selectUniqueId(UniqueId uniqueId)
Create aUniqueIdSelector
for the suppliedUniqueId
.static UriSelector
selectUri(java.lang.String uri)
Create aUriSelector
for the supplied URI.static UriSelector
selectUri(java.net.URI uri)
Create aUriSelector
for the suppliedURI
.
-
-
-
Method Detail
-
selectUri
public static UriSelector selectUri(java.lang.String uri)
Create aUriSelector
for the supplied URI.- Parameters:
uri
- the URI to select; nevernull
or blank- See Also:
UriSelector
,selectUri(URI)
,selectFile(String)
,selectFile(File)
,selectDirectory(String)
,selectDirectory(File)
-
selectUri
public static UriSelector selectUri(java.net.URI uri)
Create aUriSelector
for the suppliedURI
.- Parameters:
uri
- the URI to select; nevernull
- See Also:
UriSelector
,selectUri(String)
,selectFile(String)
,selectFile(File)
,selectDirectory(String)
,selectDirectory(File)
-
selectFile
public static FileSelector selectFile(java.lang.String path)
Create aFileSelector
for the supplied file path.This method selects the file using the supplied path as is, without verifying if the file exists.
- Parameters:
path
- the path to the file to select; nevernull
or blank- See Also:
FileSelector
,selectFile(File)
,selectDirectory(String)
,selectDirectory(File)
-
selectFile
public static FileSelector selectFile(java.io.File file)
Create aFileSelector
for the supplied file.This method selects the file in its canonical form and throws a
PreconditionViolationException
if the file does not exist.- Parameters:
file
- the file to select; nevernull
- See Also:
FileSelector
,selectFile(String)
,selectDirectory(String)
,selectDirectory(File)
-
selectDirectory
public static DirectorySelector selectDirectory(java.lang.String path)
Create aDirectorySelector
for the supplied directory path.This method selects the directory using the supplied path as is, without verifying if the directory exists.
- Parameters:
path
- the path to the directory to select; nevernull
or blank- See Also:
DirectorySelector
,selectDirectory(File)
,selectFile(String)
,selectFile(File)
-
selectDirectory
public static DirectorySelector selectDirectory(java.io.File directory)
Create aDirectorySelector
for the supplied directory.This method selects the directory in its canonical form and throws a
PreconditionViolationException
if the directory does not exist.- Parameters:
directory
- the directory to select; nevernull
- See Also:
DirectorySelector
,selectDirectory(String)
,selectFile(String)
,selectFile(File)
-
selectClasspathRoots
public static java.util.List<ClasspathRootSelector> selectClasspathRoots(java.util.Set<java.nio.file.Path> classpathRoots)
Create a list ofClasspathRootSelectors
for the supplied classpath roots (directories or JAR files).Since the supplied paths are converted to
URIs
, theFileSystem
that created them must be the default or one that has been created by an installedFileSystemProvider
.Since engines are not expected to modify the classpath, the classpath roots represented by the resulting selectors must be on the classpath of the context class loader of the thread that uses these selectors.
- Parameters:
classpathRoots
- set of directories and JAR files in the filesystem that represent classpath roots; nevernull
- Returns:
- a list of selectors for the supplied classpath roots; elements which do not physically exist in the filesystem will be filtered out
- See Also:
ClasspathRootSelector
,Thread.getContextClassLoader()
-
selectClasspathResource
public static ClasspathResourceSelector selectClasspathResource(java.lang.String classpathResourceName)
Create aClasspathResourceSelector
for the supplied classpath resource name.The name of a classpath resource must follow the semantics for resource paths as defined in
ClassLoader.getResource(String)
.If the supplied classpath resource name is prefixed with a slash (
/
), the slash will be removed.Since engines are not expected to modify the classpath, the supplied classpath resource must be on the classpath of the context class loader of the thread that uses the resulting selector.
- Parameters:
classpathResourceName
- the name of the classpath resource; nevernull
or blank- See Also:
ClasspathResourceSelector
,ClassLoader.getResource(String)
,ClassLoader.getResourceAsStream(String)
,ClassLoader.getResources(String)
-
selectModule
@API(status=EXPERIMENTAL, since="1.1") public static ModuleSelector selectModule(java.lang.String moduleName)
Create aModuleSelector
for the supplied module name.The unnamed module is not supported.
- Parameters:
moduleName
- the module name to select; nevernull
or blank- See Also:
ModuleSelector
-
selectModules
@API(status=EXPERIMENTAL, since="1.1") public static java.util.List<ModuleSelector> selectModules(java.util.Set<java.lang.String> moduleNames)
Create a list ofModuleSelectors
for the supplied module names.The unnamed module is not supported.
- Parameters:
moduleNames
- the module names to select; nevernull
, never containingnull
or blank- See Also:
ModuleSelector
-
selectPackage
public static PackageSelector selectPackage(java.lang.String packageName)
Create aPackageSelector
for the supplied package name.The default package is represented by an empty string (
""
).- Parameters:
packageName
- the package name to select; nevernull
and never containing whitespace only- See Also:
PackageSelector
-
selectClass
public static ClassSelector selectClass(java.lang.Class<?> clazz)
Create aClassSelector
for the suppliedClass
.- Parameters:
clazz
- the class to select; nevernull
- See Also:
ClassSelector
-
selectClass
public static ClassSelector selectClass(java.lang.String className)
Create aClassSelector
for the supplied class name.- Parameters:
className
- the fully qualified name of the class to select; nevernull
or blank- See Also:
ClassSelector
-
selectMethod
public static MethodSelector selectMethod(java.lang.String fullyQualifiedMethodName) throws PreconditionViolationException
Create aMethodSelector
for the supplied fully qualified method name.The following formats are supported.
[fully qualified class name]#[methodName]
[fully qualified class name]#[methodName](parameter type list)
The parameter type list is a comma-separated list of primitive names or fully qualified class names for the types of parameters accepted by the method.
Array parameter types may be specified using either the JVM's internal String representation (e.g.,
[[I
forint[][]
,[Ljava.lang.String;
forjava.lang.String[]
, etc.) or source code syntax (e.g.,int[][]
,java.lang.String[]
, etc.).Examples
Method Fully Qualified Method Name java.lang.String.chars()
java.lang.String#chars
java.lang.String.chars()
java.lang.String#chars()
java.lang.String.equalsIgnoreCase(String)
java.lang.String#equalsIgnoreCase(java.lang.String)
java.lang.String.substring(int, int)
java.lang.String#substring(int, int)
example.Calc.avg(int[])
example.Calc#avg([I)
example.Calc.avg(int[])
example.Calc#avg(int[])
example.Matrix.multiply(double[][])
example.Matrix#multiply([[D)
example.Matrix.multiply(double[][])
example.Matrix#multiply(double[][])
example.Service.process(String[])
example.Service#process([Ljava.lang.String;)
example.Service.process(String[])
example.Service#process(java.lang.String[])
example.Service.process(String[][])
example.Service#process([[Ljava.lang.String;)
example.Service.process(String[][])
example.Service#process(java.lang.String[][])
- Parameters:
fullyQualifiedMethodName
- the fully qualified name of the method to select; nevernull
or blank- Throws:
PreconditionViolationException
- See Also:
MethodSelector
-
selectMethod
public static MethodSelector selectMethod(java.lang.String className, java.lang.String methodName)
Create aMethodSelector
for the supplied class name and method name.- Parameters:
className
- the fully qualified name of the class in which the method is declared, or a subclass thereof; nevernull
or blankmethodName
- the name of the method to select; nevernull
or blank- See Also:
MethodSelector
-
selectMethod
public static MethodSelector selectMethod(java.lang.String className, java.lang.String methodName, java.lang.String methodParameterTypes)
Create aMethodSelector
for the supplied class name, method name, and method parameter types.The parameter types
String
is typically a comma-separated list of atomic types, fully qualified class names, or array types; however, the exact syntax depends on the underlying test engine.- Parameters:
className
- the fully qualified name of the class in which the method is declared, or a subclass thereof; nevernull
or blankmethodName
- the name of the method to select; nevernull
or blankmethodParameterTypes
- the method parameter types as a single string; nevernull
though potentially an empty string if the method does not accept arguments- See Also:
MethodSelector
-
selectMethod
public static MethodSelector selectMethod(java.lang.Class<?> javaClass, java.lang.String methodName)
Create aMethodSelector
for the suppliedClass
and method name.- Parameters:
javaClass
- the class in which the method is declared, or a subclass thereof; nevernull
methodName
- the name of the method to select; nevernull
or blank- See Also:
MethodSelector
-
selectMethod
public static MethodSelector selectMethod(java.lang.Class<?> javaClass, java.lang.String methodName, java.lang.String methodParameterTypes)
Create aMethodSelector
for the suppliedClass
, method name, and method parameter types.The parameter types
String
is typically a comma-separated list of atomic types, fully qualified class names, or array types; however, the exact syntax depends on the underlying test engine.- Parameters:
javaClass
- the class in which the method is declared, or a subclass thereof; nevernull
methodName
- the name of the method to select; nevernull
or blankmethodParameterTypes
- the method parameter types as a single string; nevernull
though potentially an empty string if the method does not accept arguments- See Also:
MethodSelector
-
selectMethod
public static MethodSelector selectMethod(java.lang.Class<?> javaClass, java.lang.reflect.Method method)
Create aMethodSelector
for the suppliedClass
andMethod
.- Parameters:
javaClass
- the class in which the method is declared, or a subclass thereof; nevernull
method
- the method to select; nevernull
- See Also:
MethodSelector
-
selectUniqueId
public static UniqueIdSelector selectUniqueId(UniqueId uniqueId)
Create aUniqueIdSelector
for the suppliedUniqueId
.- Parameters:
uniqueId
- theUniqueId
to select; nevernull
- See Also:
UniqueIdSelector
-
selectUniqueId
public static UniqueIdSelector selectUniqueId(java.lang.String uniqueId)
Create aUniqueIdSelector
for the supplied unique ID.- Parameters:
uniqueId
- the unique ID to select; nevernull
or blank- See Also:
UniqueIdSelector
-
-