Class MavenPaths
MavenTestingUtils used to find paths within the Maven ${project.basedir}-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static Pathprivate static PathfindMainResource(String name) static PathfindMainResourceDir(String name) Search for an expected directory in the equivalent of thesrc/maintree.static PathfindMainResourceFile(String name) Search for an expected file in the equivalent of thesrc/maintree.private static PathfindTestResource(String name) static PathfindTestResourceDir(String name) Search for an expected file in the equivalent of thesrc/maintree.static PathfindTestResourceFile(String name) Search for an expected file in the equivalent of thesrc/testtree.static PathGet the equivalent of${project.basedir}(what used to just be called${basedir}(package private) static Stringstatic PathGet thePathreference to the/targetdirectory for this project.static PathtargetTestDir(Class<?> testClazz, String methodName, String displayName) Internal test directory name creation logic.static PathtargetTestDir(String name) Resolve the test directorystatic PathtargetTestDir(org.junit.jupiter.api.extension.ExtensionContext context) Resolve the unique test directory based onExtensionContextstatic PathtargetTestDir(org.junit.jupiter.api.TestInfo info) Resolve the unique test directory based onTestInfostatic Path
-
Field Details
-
basePath
-
-
Constructor Details
-
MavenPaths
public MavenPaths()
-
-
Method Details
-
projectBase
Get the equivalent of${project.basedir}(what used to just be called${basedir}- Returns:
- the project basedir
-
targetDir
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, nor does it actually use the${project.build.directory}.This is a convenience method for
MavenPaths.projectBase().resolve("target")but ensures that the directory exists before returning it.- Returns:
- the directory path to the
/targetdirectory.
-
targetTests
-
targetTestDir
Resolve the unique test directory based onExtensionContext- Parameters:
context- theExtensionContextto buildtarget/tests/{name}from- Returns:
- the unique test path for the context
-
targetTestDir
Resolve the unique test directory based onTestInfo- Parameters:
info- theTestInfoto buildtarget/tests/{name}from- Returns:
- the unique test path for the context
-
targetTestDir
Resolve the test directory- Parameters:
name- the to resolvetarget/tests/{name}from- Returns:
- the test path for the context
-
targetTestDir
Internal test directory name creation logic.This creates a name under
target/tests/{clazzName_condensed}/{name}where{name}is either{methodName}{displayName}or{displayName}depending on if{methodName}exists or not.- Parameters:
testClazz- the test class namemethodName- the method name (usually fromExtensionContext.getTestMethod()orTestInfo.getTestMethod())displayName- the display name (usually fromExtensionContext.getDisplayName()orTestInfo.getDisplayName())
-
findMainResourceFile
Search for an expected file in the equivalent of the
src/maintree.Search order:
src/main/resources/${name}target/classes/${name}
If name exists anywhere in the search tree, but is not a File, this results in an
AssertionError- Parameters:
name- the name to search for (must not start with/. use only URI path separator syntax)- Returns:
- the Path (always a regular file)
- Throws:
AssertionError- if name does not exist, or resulting path is not a File
-
findMainResourceDir
Search for an expected directory in the equivalent of the
src/maintree.Search order:
src/main/resources/${name}target/classes/${name}
If name exists anywhere in the search tree, but is not a Directory, this results in an
AssertionError- Parameters:
name- the name to search for (must not start with/. use only URI path separator syntax)- Returns:
- the Path (always a directory)
- Throws:
AssertionError- if name does not exist, or resulting path is not a directory
-
findTestResourceFile
Search for an expected file in the equivalent of the
src/testtree.Search order:
src/test/resources/${name}target/test-classes/${name}ClassLoader.getResource(${name})
If name exists anywhere in the search tree, but is not a File, this results in an
AssertionError- Parameters:
name- the name to search for (must not start with/. use only URI path separator syntax)- Returns:
- the Path (always a regular file)
- Throws:
AssertionError- if name does not exist, or resulting path is not a File
-
findTestResourceDir
Search for an expected file in the equivalent of the
src/maintree.Search order:
src/main/resources/${name}target/classes/${name}ClassLoader.getResource(${name})
If name exists anywhere in the search tree, but is not a Directory, this results in an
AssertionError- Parameters:
name- the name to search for (must not start with/. use only URI path separator syntax)- Returns:
- the Path (always a directory)
- Throws:
AssertionError- if name does not exist, or resulting path is not a Directory
-
absolute
-
findMainResource
-
findTestResource
-
safename
-