public final class JUnitUtils extends Object
Modifier and Type | Field and Description |
---|---|
static String |
TESTS_ROOT_NAME |
Constructor and Description |
---|
JUnitUtils(Project project) |
Modifier and Type | Method and Description |
---|---|
static DataObject |
createSuiteTest(FileObject targetRootFolder,
FileObject targetFolder,
String suiteName,
Map<org.netbeans.modules.gsf.testrunner.plugin.CommonPlugin.CreateTestParam,Object> params) |
SourceGroup[] |
getJavaSourceGroups() |
Project |
getProject() |
FileObject[] |
getSourceFoldersRaw(FileObject testFolder)
Returns an array of source folders corresponding to the given test
folder - may contain
null s. |
Map<SourceGroup,Object[]> |
getSourcesToTestsMap(boolean sourceGroupsOnly) |
static Collection<FileObject> |
getTestFolders(Project project)
Identifies and collects root test folders of a given project.
|
FileObject[] |
getTestFoldersRaw(FileObject srcFolder)
Returns an array of test folders corresponding to the given source
folder - may contain
null s. |
static Collection |
getTestTargets(Project project,
boolean sourceGroupsOnly)
Identifies and collects
SourceGroup s and folders
of a given project which may serve as target folders for newly created
test classes. |
Object[] |
getTestTargets(SourceGroup sourceGroup,
boolean sourceGroupsOnly)
Returns test targets for the given
SourceGroup . |
static boolean |
isInstanceOfDefaultPlugin(JUnitPlugin plugin) |
static boolean |
isValidClassName(String className) |
static void |
logJUnitUsage(URI projectURI) |
static FileObject[] |
skipNulls(FileObject[] fileObjs) |
public static final String TESTS_ROOT_NAME
public JUnitUtils(Project project)
public static void logJUnitUsage(URI projectURI)
public static boolean isInstanceOfDefaultPlugin(JUnitPlugin plugin)
public static DataObject createSuiteTest(FileObject targetRootFolder, FileObject targetFolder, String suiteName, Map<org.netbeans.modules.gsf.testrunner.plugin.CommonPlugin.CreateTestParam,Object> params)
public static Collection getTestTargets(Project project, boolean sourceGroupsOnly)
SourceGroup
s and folders
of a given project which may serve as target folders for newly created
test classes.project
- project whose folders are to be checkedsourceGroupsOnly
- return only SourceGroup
s
- ignore target folders not having
a corresponding SourceGroup
FileObject
s
or SourceGroup
s (or both);
it may be empty but not null
public static Collection<FileObject> getTestFolders(Project project)
project
- project whose test folders are to be foundFileObject
s, possibly empty
(but not null
)public Project getProject()
public Map<SourceGroup,Object[]> getSourcesToTestsMap(boolean sourceGroupsOnly)
public Object[] getTestTargets(SourceGroup sourceGroup, boolean sourceGroupsOnly)
SourceGroup
.
The test targets are folders which are searched when tests for a class
from the SourceGroup
are to be found. Each of the returned
test targets may be either SourceGroup
(representing
a folder plus additional information such as display name) or simply
a FileObject
representing a folder.
If parameter includeSourceGroups
is false
,
only SourceGroup
s are returned (target folders without
corresponding SourceGroup
s are ignored).sourceGroup
- source group to find test targets forsourceGroupsOnly
- skip target folders without matching
SourceGroup
FileObject
s
or SourceGroup
s (or both);
it may be empty but not null
CommonTestUtil.getFileObject2SourceGroupMap(org.netbeans.api.project.Project)
public FileObject[] getTestFoldersRaw(FileObject srcFolder)
null
s.srcFolder
- FileObject
representing source code root,
for which test root folders should be foundFileObject
s representing test root
folders, possibly with superfluous null
elementsJUnitUtils.getSourceFoldersRaw(org.openide.filesystems.FileObject)
public FileObject[] getSourceFoldersRaw(FileObject testFolder)
null
s.testFolder
- FileObject
representing source code root,
for which source root folders should be foundFileObject
s representing source root
folders, possibly with superfluous null
elementsJUnitUtils.getTestFoldersRaw(org.openide.filesystems.FileObject)
public static FileObject[] skipNulls(FileObject[] fileObjs)
public SourceGroup[] getJavaSourceGroups()
public static boolean isValidClassName(String className)