Class MavenTestingUtils
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic FileDeprecated, for removal: This API element is subject to removal in a future version.static PathObtain aPathreference to the maven ${basedir} for the module.static URIGet the Basedir for the project as a URIstatic FilegetProjectDir(String path) Deprecated, for removal: This API element is subject to removal in a future version.usegetProjectDirPath(String)insteadstatic PathgetProjectDirPath(String path) Get aPathreference to a required directory in the project module path, based on relative path references from maven ${basedir}.static FilegetProjectFile(String path) Deprecated, for removal: This API element is subject to removal in a future version.usegetProjectFilePath(String)insteadstatic PathgetProjectFilePath(String path) Get aPathreference to a required file in the project module path, based on relative path references from maven ${basedir}.static FileDeprecated, for removal: This API element is subject to removal in a future version.usegetTargetPath()insteadstatic FilegetTargetFile(String path) Deprecated, for removal: This API element is subject to removal in a future version.usegetTargetPath(String)insteadstatic PathGet thePathreference to the/targetdirectory for this project.static PathgetTargetPath(String path) Create aPathobject for a path in the /target directory.static FileDeprecated, for removal: This API element is subject to removal in a future version.usegetTargetTestingPath()insteadstatic FilegetTargetTestingDir(String testname) Deprecated, for removal: This API element is subject to removal in a future version.usegetTargetTestingPath(String)insteadstatic FilegetTargetTestingDir(org.junit.jupiter.api.TestInfo testInfo) Deprecated, for removal: This API element is subject to removal in a future version.usegetTargetTestingPath(TestInfo)insteadstatic PathGet aPathreference to the maven${basedir}/target/tests/path.static PathgetTargetTestingPath(Class<?> testclass, String testmethodname) Obtain a testing directory reference in maven${basedir}/target/tests/${condensed-classname}/${methodname}path that uses an condensed directory name based on the testclass and subdirectory based on the testmethod being run.static PathgetTargetTestingPath(String testname) Get aPathreference to the maven${basedir}/target/tests/test-${testname}using the supplied testnamestatic PathgetTargetTestingPath(org.junit.jupiter.api.TestInfo testInfo) Get aPathreference to the${basedir}/target/tests/test-${testname}directory.static URIgetTargetURI(String path) Get a URI reference to a path (File or Dir) within the maven "${basedir}/target" directory.static URLgetTargetURL(String path) Get a URL reference to a path (File or Dir) within the maven "${basedir}/target" directory.private static MavenTestingUtils.TestIDDeprecated, for removal: This API element is subject to removal in a future version.use Junit5TestInfoinsteadstatic FilegetTestResourceDir(String name) Deprecated, for removal: This API element is subject to removal in a future version.usegetTestResourcePathDir(String)insteadstatic FilegetTestResourceFile(String name) Deprecated, for removal: This API element is subject to removal in a future version.usegetTestResourcePathFile(String)insteadstatic PathgetTestResourcePath(String name) Get a path resource (File or Dir) from the maven${basedir}/src/test/resourcedirectory.static PathgetTestResourcePathDir(String name) Get a dir from the maven${basedir}/src/test/resourcedirectory.static PathGet a file from the maven${basedir}/src/test/resourcedirectory.static FileDeprecated, for removal: This API element is subject to removal in a future version.usegetTestResourcesPath()insteadstatic PathGet thePathreference to the maven${basedir}/src/test/resourcesdirectory
-
Field Details
-
basePath
-
testResourcesPath
-
targetPath
-
-
Constructor Details
-
MavenTestingUtils
private MavenTestingUtils()
-
-
Method Details
-
getBaseDir
Deprecated, for removal: This API element is subject to removal in a future version.usegetBasePath()insteadObtain aFilereference to the maven ${basedir} for the module.Convenience method for
MavenTestingUtils.getBasePath().toFile()- Returns:
- the equivalent to the maven ${basedir} property.
- See Also:
-
getBasePath
Obtain aPathreference to the maven ${basedir} for the module.Note: while running in maven, the ${basedir} is populated by maven and used by the surefire-plugin.
While running in eclipse, the ${basedir} property is unset, resulting in this method falling back to ${user.dir} equivalent use.- Returns:
- the equivalent to the maven ${basedir} property.
-
getBaseURI
Get the Basedir for the project as a URI- Returns:
- the URI for the project basedir
-
getTargetDir
Deprecated, for removal: This API element is subject to removal in a future version.usegetTargetPath()insteadGet theFilereference to the/targetdirectory for this project.Convenience method for
MavenTestingUtils.getTargetPath().toFile()- Returns:
- the directory path to the target directory.
- See Also:
-
getTargetPath
Get thePathreference to the/targetdirectory for this project.This is roughly equivalent to the
${project.build.directory}property.Note: this implementation does not inspect the
pom.xmlfor non-standard locations of the${project.build.directory}property. (it always assumes/target)- Returns:
- the directory path to the
/targetdirectory.
-
getTargetFile
Deprecated, for removal: This API element is subject to removal in a future version.usegetTargetPath(String)insteadCreate aFileobject for a path in the /target directory.Convenience method for
MavenTestingUtils.getTargetPath("foo").toFile()- Parameters:
path- the path desired, no validation of existence is performed.- Returns:
- the File to the path.
- See Also:
-
getTargetPath
Create aPathobject for a path in the /target directory.- Parameters:
path- the path desired, no validation of existence is performed.- Returns:
- the File to the path.
-
getTargetTestingDir
Deprecated, for removal: This API element is subject to removal in a future version.usegetTargetTestingPath()insteadGet aFilereference to the maven${basedir}/target/tests/directory.Convenience method for
MavenTestingUtils.getTargetTestingPath().toFile()- Returns:
- the maven
${basedir}/target/tests/directory. Note: will not validate that the directory exists, or create the directory)
-
getTargetTestingPath
Get aPathreference to the maven${basedir}/target/tests/path.- Returns:
- the maven
${basedir}/target/tests/directory. Note: will not validate that the directory exists, or create the directory)
-
getTargetTestingDir
Deprecated, for removal: This API element is subject to removal in a future version.usegetTargetTestingPath(String)insteadGet aFilereference to the maven${basedir}/target/tests/test-${testname}using the supplied testnameConvenience method for
MavenTestingUtils.getTargetTestingPath(testname).toFile()- Parameters:
testname- the testname to create directory against.- Returns:
- the maven
${basedir}/target/tests/test-${testname}directory
-
getTargetTestingPath
Get aPathreference to the maven${basedir}/target/tests/test-${testname}using the supplied testname- Parameters:
testname- the testname to create directory against.- Returns:
- the maven
${basedir}/target/tests/test-${testname}directory
-
getTargetTestingDir
@Deprecated(forRemoval=true, since="6.0") public static File getTargetTestingDir(org.junit.jupiter.api.TestInfo testInfo) Deprecated, for removal: This API element is subject to removal in a future version.usegetTargetTestingPath(TestInfo)insteadGet aFilereference to the${basedir}/target/tests/test-${testname}directory. Uses the JUnit 5.xTestInfo.getDisplayName()to make a unique directory name per test.Convenience method for
MavenTestingUtils.getTargetTestingPath(TestCase.getName()).toFile()- Parameters:
testInfo- the junit 5.x testcase to base this new directory on.- Returns:
- the maven
${basedir}/target/tests/test-${testname}directory.
-
getTargetTestingPath
Get aPathreference to the${basedir}/target/tests/test-${testname}directory. Uses the JUnit 5.xTestInfo.getDisplayName()to make a unique directory name per test.Convenience method for
MavenTestingUtils.getTargetTestingPath(TestCase.getName())- Parameters:
testInfo- the junit 5.x testcase to base this new directory on.- Returns:
- the maven
${basedir}/target/tests/test-${testname}directory. - See Also:
-
getTargetURI
Get a URI reference to a path (File or Dir) within the maven "${basedir}/target" directory.Convenience method for
MavenTestingUtils.getTargetPath(path).toUri()- Parameters:
path- the relative path to use- Returns:
- the URI reference to the target path
-
getTargetURL
Get a URL reference to a path (File or Dir) within the maven "${basedir}/target" directory.Convenience method for
MavenTestingUtils.getTargetURI(path).toURL()- Parameters:
path- the relative path to use- Returns:
- the URL reference to the target path
- Throws:
MalformedURLException- if unable to create a new target url due to URL error.
-
getTargetTestingPath
Obtain a testing directory reference in maven${basedir}/target/tests/${condensed-classname}/${methodname}path that uses an condensed directory name based on the testclass and subdirectory based on the testmethod being run.- Parameters:
testclass- the class for the test casetestmethodname- the test method name- Returns:
- the File path to the testname specific testing directory underneath the
${basedir}/target/tests/sub directory - See Also:
-
getProjectFile
Deprecated, for removal: This API element is subject to removal in a future version.usegetProjectFilePath(String)insteadGet aFilereference to a required file in the project module path, based on relative path references from maven ${basedir}.Note: will throw assertion error if path does point to an existing file
Convenience method for
MavenTestingUtils.getProjectFilePath(path).toFile()- Parameters:
path- the relative path to reference- Returns:
- the file reference (must exist)
-
getProjectFilePath
Get aPathreference to a required file in the project module path, based on relative path references from maven ${basedir}.Note: will throw assertion error if path does point to an existing file
- Parameters:
path- the relative path to reference- Returns:
- the file reference (must exist)
-
getProjectDir
Deprecated, for removal: This API element is subject to removal in a future version.usegetProjectDirPath(String)insteadGet a directory reference to a required directory in the project module path, based on relative path references from maven ${basedir}.Note: will throw assertion error if path does point to an existing directory
Convenience method for
MavenTestingUtils.getProjectDirPath(path).toFile()- Parameters:
path- the relative path to reference- Returns:
- the directory reference (must exist)
-
getProjectDirPath
Get aPathreference to a required directory in the project module path, based on relative path references from maven ${basedir}.Note: will throw assertion error if path does point to an existing directory
- Parameters:
path- the relative path to reference- Returns:
- the directory reference (must exist)
-
getTestID
Deprecated, for removal: This API element is subject to removal in a future version.use Junit5TestInfoinsteadUsing junit 3.x naming standards for unit tests and test method names, attempt to discover the unit test name from the execution stack.- Returns:
- the unit test id found via execution stack and junit 3.8 naming conventions.
-
getTestResourcesDir
Deprecated, for removal: This API element is subject to removal in a future version.usegetTestResourcesPath()insteadGet theFilereference to the maven${basedir}/src/test/resourcesdirectoryConvenience method for
MavenTestingUtils.getTestResourcesPath().toFile()- Returns:
- the directory
Fileto the maven${basedir}/src/test/resourcesdirectory
-
getTestResourcesPath
Get thePathreference to the maven${basedir}/src/test/resourcesdirectory- Returns:
- the directory
Pathto the maven${basedir}/src/test/resourcesdirectory
-
getTestResourceDir
Deprecated, for removal: This API element is subject to removal in a future version.usegetTestResourcePathDir(String)insteadGet a dir from the maven${basedir}/src/test/resourcedirectory.Note: will throw assertion error if path does point to an existing directory
Convenience method for
MavenTestingUtils.getTestResourcesPathDir(name).toFile()- Parameters:
name- the name of the path to get (it must exist as a dir)- Returns:
- the dir in the maven
${basedir}/src/test/resourcepath
-
getTestResourcePathDir
Get a dir from the maven${basedir}/src/test/resourcedirectory.Note: will throw assertion error if path does point to an existing directory
- Parameters:
name- the name of the path to get (it must exist as a dir)- Returns:
- the dir in the maven
${basedir}/src/test/resourcepath
-
getTestResourceFile
Deprecated, for removal: This API element is subject to removal in a future version.usegetTestResourcePathFile(String)insteadGet a file from the maven${basedir}/src/test/resourcedirectory.Note: will throw assertion error if path does point to an existing file
- Parameters:
name- the name of the path to get (it must exist as a file)- Returns:
- the file in maven
${basedir}/src/test/resource
-
getTestResourcePathFile
Get a file from the maven${basedir}/src/test/resourcedirectory.Note: will throw assertion error if path does point to an existing file
- Parameters:
name- the name of the path to get (it must exist as a file)- Returns:
- the file in maven
${basedir}/src/test/resource
-
getTestResourcePath
Get a path resource (File or Dir) from the maven${basedir}/src/test/resourcedirectory.- Parameters:
name- the name of the path to get (it must exist)- Returns:
- the path in maven
${basedir}/src/test/resource
-
getBasePath()instead