module documentation

Helpers to compile Java and run unit tests with coverage.

Function classForPath Converts a path relative to root directory to a class name.
Function compileJava A default java compilation command. Kept simple. If you need a more elaborate setup, it is easy enough to write your own, rather than this function being extremely configurable and configure it.
Function jacocoReport Creates a coverage report from the output of jacocoRunJunit4.
Function jacocoRunJunit4 Runs junit4 tests with the default JunitCore class.
Constant _PATHSEP Undocumented
def classForPath(classpathEntry: Path, p: Path) -> str:

Converts a path relative to root directory to a class name.

For example if classpathEntry is build/test and the p is build/test/my/package/Dodo.class, the result is my.package.Dodo.

Parameters
classpathEntry:Patha directory containing compiled classes
p:Patha *.class file within classpathEntry
Returns
strUndocumented
def compileJava(targetPath: os.PathLike, srcPath: os.PathLike, *classpath: Path):

A default java compilation command. Kept simple. If you need a more elaborate setup, it is easy enough to write your own, rather than this function being extremely configurable and configure it.

Parameters
targetPath:os.PathLikea Path where to drop the compiled files
srcPath:os.PathLikethe source files directory
*classpath:Pathclasspath members
def jacocoReport(targetPath: Path, jacocoCli: Path, jacocoData: Path, classFiles: Path, sourceFiles: Path):

Creates a coverage report from the output of jacocoRunJunit4.

Parameters
targetPath:Paththe directory where to place the coverage html files
jacocoCli:Paththe jar org.jacoco.cli...jar.
jacocoData:Paththe output of jacocoRunJunit4
classFiles:Paththe compiled classes classpath
sourceFiles:Pathdirectory with the source files
def jacocoRunJunit4(targetPath: Path, testClassesPath: Path, testClassRe: str | re.Pattern, jacocoJar: Path, *classpath: Path):

Runs junit4 tests with the default JunitCore class.

Parameters
targetPath:Paththe path of the coverage data to produce by running with jacoco
testClassesPath:Patha Path representing a classpath entry for test classes
testClassRe:str | re.Patterna regular expression or compiled pattern which has to be matched by *.class files on the testClassesPath to be included as a test class. Classes with a $ in the name are always excluded. If there are no helper classses on the classpath, just use ., otherwise, depending on your convention, ^Test.* or .*Test[.]class$ may be what you need. Only the file name, without any leading path name, will be searched with the pattern.
jacocoJar:Paththe jar org.jacoco.agent...jar, not going on the class path
*classpath:Pathfurther classpath entries, i.e. classes, junit jar, etc.
_PATHSEP =

Undocumented

Value
';' if sys.platform == 'windows' else ':'