* If a list is not explicitly supplied then PIT will default to a list of common logging packages as follows *
*
* If the feature {@code FLOGCALL} is disabled, this parameter is ignored and logging calls are also mutated.
*
* @param avoidCallsTo the list of packages
* @return this operation instance
* @see #avoidCallsTo(String...)
*/
public PitestOperation avoidCallsTo(Collection
* If a list is not explicitly supplied then PIT will default to a list of common logging packages as follows
*
*
* If the feature {@code FLOGCALL} is disabled, this parameter is ignored and logging calls are also mutated.
*
* @param avoidCallTo one or more packages
* @return this operation instance
* @see #avoidCallsTo(Collection)
*/
public PitestOperation avoidCallsTo(String... avoidCallTo) {
return avoidCallsTo(List.of(avoidCallTo));
}
/**
* List of packages and classes which are to be considered outside the scope of mutation. Any lines of code
* containing calls to these classes will not be mutated.
*
* If a list is not explicitly supplied then PIT will default to a list of common logging packages as follows
*
*
* If the feature {@code FLOGCALL} is disabled, this parameter is ignored and logging calls are also mutated.
* Additional classpath entries to use when looking for tests and mutable code.
*
* @param path one or more paths
* @return this operation instance
* @see #classPath(Collection)
*/
public PitestOperation classPath(String... path) {
return classPath(List.of(path));
}
/**
* List of packages and classes which are to be considered outside the scope of mutation. Any lines of code
* containing calls to these classes will not be mutated.
*
* If a list is not explicitly supplied then PIT will default to a list of common logging packages as follows
*
*
* If the feature {@code FLOGCALL} is disabled, this parameter is ignored and logging calls are also mutated.
* Additional classpath entries to use when looking for tests and mutable code.
*
* @param path one or more paths
* @return this operation instance
* @see #classPathPaths(Collection)
*/
public PitestOperation classPath(Path... path) {
return classPathPaths(List.of(path));
}
/**
* Additional classpath entries to use when looking for tests and mutable code.
*
* @param path the list of paths
* @return this operation instance
* @see #classPath(String...)
*/
public PitestOperation classPath(Collection
* If a list is not explicitly supplied then PIT will default to a list of common logging packages as follows
*
*
* If the feature {@code FLOGCALL} is disabled, this parameter is ignored and logging calls are also mutated.
* Additional classpath entries to use when looking for tests and mutable code.
*
* @param path one or more paths
* @return this operation instance
* @see #classPathFiles(Collection)
*/
public PitestOperation classPath(File... path) {
return classPathFiles(List.of(path));
}
/**
* File with a list of additional classpath elements (one per line).
*
* @param file the file
* @return this operation instance
*/
public PitestOperation classPathFile(String file) {
if (isNotBlank(file)) {
options_.put("--classPathFile", file);
}
return this;
}
/**
* Additional classpath entries to use when looking for tests and mutable code.
*
* @param path the list of paths
* @return this operation instance
* @see #classPath(File...)
*/
public PitestOperation classPathFiles(Collection
* The algorithm cannot easily distinguish between inlined copies of code, and genuine duplicate instructions on
* the same line within a {@code finally} block.
*
* In the case of any doubt PIT will act cautiously and assume that the code is not inlined.
*
* This will be detected as two separate inlined instructions
*
* Defaults to {@code true}
*
* @param isDetectInlinedCode {@code true} or {@code false}
* @return this operation instance
*/
public PitestOperation detectInlinedCode(boolean isDetectInlinedCode) {
if (isDetectInlinedCode) {
options_.put("--detectInlinedCode", TRUE);
} else {
options_.put("--detectInlinedCode", FALSE);
}
return this;
}
/**
* List of globs to match against class names. Matching classes will be excluded from mutation.
*
* @param excludedClass the excluded classws
* @return this operation instance
* @see #excludedClasses(Collection)
*/
public PitestOperation excludedClasses(String... excludedClass) {
return excludedClasses(List.of(excludedClass));
}
/**
* List of globs to match against class names. Matching classes will be excluded from mutation.
*
* @param excludedClasses the excluded classes
* @return this operation instance
* @see #excludedClasses(String...)
*/
public PitestOperation excludedClasses(Collection
* Defaults to {@code false}
*
* @param jsExport {@code true} or {@code false}
* @return this operation instance
*/
public PitestOperation exportLineCoverage(boolean jsExport) {
if (jsExport) {
options_.put("--exportLineCoverage", TRUE);
} else {
options_.put("--exportLineCoverage", FALSE);
}
return this;
}
/**
* Whether to throw an error when no mutations found.
*
* Defaults to {@code true}
*
* @param isFail {@code true} or {@code false}
* @return this operation instance
*/
public PitestOperation failWhenNoMutations(boolean isFail) {
if (isFail) {
options_.put("--failWhenNoMutations", TRUE);
} else {
options_.put("--failWhenNoMutations", FALSE);
}
return this;
}
/**
* List of features to enable/disable
*
* @param feature the list of features
* @return this operation instance
* @see #features(String...)
*/
public PitestOperation features(Collection
* Defaults to {@code true}
*
* @param isLaunchClasspath {@code true} or {@code false}
* @return this operation instance
*/
public PitestOperation includeLaunchClasspath(boolean isLaunchClasspath) {
if (isLaunchClasspath) {
options_.put("--includeLaunchClasspath", TRUE);
} else {
options_.put("--includeLaunchClasspath", FALSE);
}
return this;
}
/**
* list of TestNG groups/JUnit categories to include in mutation analysis. Note that only class level categories
* are supported.
*
* @param includedGroup one or more included groups
* @return this operation instance
* @see #includedGroups(Collection)
*/
public PitestOperation includedGroups(String... includedGroup) {
return includedGroups(List.of(includedGroup));
}
/**
* list of TestNG groups/JUnit categories to include in mutation analysis. Note that only class level categories are
* supported.
*
* @param includedGroups the list of included groups
* @return this operation instance
* @see #includedGroups(String...)
*/
public PitestOperation includedGroups(Collection
* Default is {@code UTF-8}.
*
* @param encoding the encoding
* @return this operation instance
*/
public PitestOperation inputEncoding(String encoding) {
if (isNotBlank(encoding)) {
options_.put("--inputEncoding", encoding);
}
return this;
}
/*
* Determines if a string is not blank.
*/
private boolean isNotBlank(String s) {
return s != null && !s.isBlank();
}
/**
* Argument string to use when PIT launches child processes. This is most commonly used to increase the amount of
* memory available to the process, but may be used to pass any valid JVM argument.
*
* @param args one or moe args
* @return this operation instance
* @see #jvmArgs(Collection)
*/
public PitestOperation jvmArgs(String... args) {
return jvmArgs(List.of(args));
}
/**
* Argument string to use when PIT launches child processes. This is most commonly used to increase the amount of
* memory available to the process, but may be used to pass any valid JVM argument.
*
* @param args the list of args
* @return this operation instance
* @see #jvmArgs(String...)
*/
public PitestOperation jvmArgs(Collection
* If no mutableCodePath is supplied PIT will default to considering anything not defined within a jar or zip file
* as being a candidate for mutation.
*
* PIT will always attempt not to mutate test classes even if they are defined on a mutable path.
*
* @param path one or one paths
* @return this operation instance
* @see #mutableCodePaths(Collection)
*/
public PitestOperation mutableCodePaths(String... path) {
return mutableCodePaths(List.of(path));
}
/**
* List of classpaths which should be considered to contain mutable code. If your build maintains separate output
* directories for tests and production classes this parameter should be set to your code output directory in order
* to avoid mutating test helper classes etc.
*
* If no mutableCodePath is supplied PIT will default to considering anything not defined within a jar or zip file
* as being a candidate for mutation.
*
* PIT will always attempt not to mutate test classes even if they are defined on a mutable path.
*
* @param path one or one paths
* @return this operation instance
* @see #mutableCodePathsPaths(Collection)
*/
public PitestOperation mutableCodePaths(Path... path) {
return mutableCodePathsPaths(List.of(path));
}
/**
* List of classpaths which should be considered to contain mutable code. If your build maintains separate output
* directories for tests and production classes this parameter should be set to your code output directory in order
* to avoid mutating test helper classes etc.
*
* If no mutableCodePath is supplied PIT will default to considering anything not defined within a jar or zip file
* as being a candidate for mutation.
*
* PIT will always attempt not to mutate test classes even if they are defined on a mutable path.
*
* @param path one or one paths
* @return this operation instance
* @see #mutableCodePathsFiles(Collection)
*/
public PitestOperation mutableCodePaths(File... path) {
return mutableCodePathsFiles(List.of(path));
}
/**
* List of classpaths which should be considered to contain mutable code. If your build maintains separate output
* directories for tests and production classes this parameter should be set to your code output directory in order
* to avoid mutating test helper classes etc.
*
* If no mutableCodePath is supplied PIT will default to considering anything not defined within a jar or zip file
* as being a candidate for mutation.
*
* PIT will always attempt not to mutate test classes even if they are defined on a mutable path.
*
* @param paths the list of paths
* @return this operation instance
* @see #mutableCodePaths(String...)
*/
public PitestOperation mutableCodePaths(Collection
* If no mutableCodePath is supplied PIT will default to considering anything not defined within a jar or zip file
* as being a candidate for mutation.
*
* PIT will always attempt not to mutate test classes even if they are defined on a mutable path.
*
* @param paths the list of paths
* @return this operation instance
* @see #mutableCodePaths(File...)
*/
public PitestOperation mutableCodePathsFiles(Collection
* If no mutableCodePath is supplied PIT will default to considering anything not defined within a jar or zip file
* as being a candidate for mutation.
*
* PIT will always attempt not to mutate test classes even if they are defined on a mutable path.
*
* @param paths the list of paths
* @return this operation instance
* @see #mutableCodePaths(Path...)
*/
public PitestOperation mutableCodePathsPaths(Collection
* Defaults to {@code gregor}
*
* @param engine the engine
* @return this operation instance
*/
public PitestOperation mutationEngine(String engine) {
options_.put("--mutationEngine", engine);
return this;
}
/**
* Mutation score threshold below which the build will fail. This is an integer percent (0-100) that represents the
* fraction of killed mutations out of all mutations.
*
* Please bear in mind that your build may contain equivalent mutations. Careful thought must therefore be given
* when selecting a threshold.
*
* @param threshold the threshold
* @return this operation instance
*/
public PitestOperation mutationThreshold(int threshold) {
if (threshold >= 0 && threshold <= 100) {
options_.put("--mutationThreshold", String.valueOf(threshold));
}
return this;
}
/**
* Maximum number of mutations to include.
*
* @param size the size
* @return this operation instance
*/
public PitestOperation mutationUnitSize(int size) {
options_.put("--mutationUnitSize", String.valueOf(size));
return this;
}
/**
* List of mutation operators.
*
* @param mutator one or more mutators
* @return this operation instance
* @see #mutators(Collection)
*/
public PitestOperation mutators(String... mutator) {
options_.put("--mutators", String.join(",", Arrays.stream(mutator).filter(this::isNotBlank).toList()));
return this;
}
/**
* List of mutation operators.
*
* @param mutators the list of mutators
* @return this operation instance
* @see #mutators(String...)
*/
public PitestOperation mutators(Collection
* Default is {@code UTF-8}.
*
* @param encoding the encoding
* @return this operation instance
*/
public PitestOperation outputEncoding(String encoding) {
if (isNotBlank(encoding)) {
options_.put("--outputEncoding", encoding);
}
return this;
}
/**
* A list of formats in which to write mutation results as the mutations are analysed.
* Supported formats are {@code HTML}, {@code XML}, {@code CSV}.
*
* Defaults to {@code HTML}.
*
* @param outputFormat one or more output formats
* @return this operation instance
* @see #outputFormatsFiles(Collection)
*/
public PitestOperation outputFormats(File... outputFormat) {
return outputFormatsFiles(List.of(outputFormat));
}
/**
* A list of formats in which to write mutation results as the mutations are analysed.
* Supported formats are {@code HTML}, {@code XML}, {@code CSV}.
*
* Defaults to {@code HTML}.
*
* @param outputFormat one or more output formats
* @return this operation instance
* @see #outputFormatsPaths(Collection)
*/
public PitestOperation outputFormats(Path... outputFormat) {
return outputFormatsPaths(List.of(outputFormat));
}
/**
* A list of formats in which to write mutation results as the mutations are analysed.
* Supported formats are {@code HTML}, {@code XML}, {@code CSV}.
*
* Defaults to {@code HTML}.
*
* @param outputFormat one or more output formats
* @return this operation instance
* @see #outputFormats(Collection)
*/
public PitestOperation outputFormats(String... outputFormat) {
return outputFormats(List.of(outputFormat));
}
/**
* A list of formats in which to write mutation results as the mutations are analysed.
* Supported formats are {@code HTML}, {@code XML}, {@code CSV}.
*
* Defaults to {@code HTML}.
*
* @param outputFormats the list of output formats
* @return this operation instance
* @see #outputFormats(String...)
*/
public PitestOperation outputFormats(Collection
* Defaults to {@code HTML}.
*
* @param outputFormats the list of output formats
* @return this operation instance
* @see #outputFormats(File...)
*/
public PitestOperation outputFormatsFiles(Collection
* Defaults to {@code HTML}.
*
* @param outputFormats the list of output formats
* @return this operation instance
* @see #outputFormats(Path...)
*/
public PitestOperation outputFormatsPaths(Collection
* Default is {@code false}
*
* @param isSkipFail {@code true} or {@code false}
* @return this operation instance
*/
public PitestOperation skipFailingTests(boolean isSkipFail) {
if (isSkipFail) {
options_.put("--skipFailingTests", TRUE);
} else {
options_.put("--skipFailingTests", FALSE);
}
return this;
}
/**
* The folder(s) containing the source code.
*
* @param dir one or more directories
* @return this operation instance
* @see #sourceDirs(Collection)
*/
public PitestOperation sourceDirs(String... dir) {
return sourceDirs(List.of(dir));
}
/**
* The folder(s) containing the source code.
*
* @param dir one or more directories
* @return this operation instance
* @see #sourceDirsFiles(Collection)
*/
public PitestOperation sourceDirs(File... dir) {
return sourceDirsFiles(List.of(dir));
}
/**
* The folder(s) containing the source code.
*
* @param dir one or more directories
* @return this operation instance
* @see #sourceDirsPaths(Collection)
*/
public PitestOperation sourceDirs(Path... dir) {
return sourceDirsPaths(List.of(dir));
}
/**
* The folder(s) containing the source code.
*
* @param dirs the list of directories
* @return this operation instance
* @see #sourceDirs(String...)
*/
public PitestOperation sourceDirs(Collection
* For example:
*
* For example:
*
* This parameter can be used to point PIT to a top level suite or suites. Custom suites such as
* ClassPathSuite are supported.
*
* @param test one or more tests
* @return this operation instance
* @see #targetTests(Collection)
*/
public PitestOperation targetTests(String... test) {
return targetTests(List.of(test));
}
/**
* A list of globs can be supplied to this parameter to limit the tests available to be run.
* If this parameter is not supplied then any test fixture that matched targetClasses may be used, it is however
* recommended that this parameter is always explicitly set.
*
* This parameter can be used to point PIT to a top level suite or suites. Custom suites such as
* ClassPathSuite are supported.
*
* @param tests the list of tests
* @return this operation instance
* @see #targetTests(String...)
*/
public PitestOperation targetTests(Collection
* Defaults to {@code 4000}
*
* @param factor the factor amount
* @return this operation instance
*/
public PitestOperation timeoutConst(int factor) {
options_.put("--timeoutConst", String.valueOf(factor));
return this;
}
/**
* A factor to apply to the normal runtime of a test when considering if it is stuck in an infinite loop.
*
* Defaults to {@code 1.25}
*
* @param factor the factor
* @return this operation instance
*/
public PitestOperation timeoutFactor(double factor) {
options_.put("--timeoutFactor", String.valueOf(factor));
return this;
}
/**
* By default, PIT will create a date and time stamped folder for its output each time it is run. This can can make
* automation difficult, so the behaviour can be suppressed by passing {@code false}.
*
* Defaults to {@code false}
*
* @param isTimestamped {@code true} or {@code false}
* @return this operation instance
*/
public PitestOperation timestampedReports(boolean isTimestamped) {
if (isTimestamped) {
options_.put("--timestampedReports", TRUE);
} else {
options_.put("--timestampedReports", FALSE);
}
return this;
}
/**
* Support large classpaths by creating a classpath jar.
*
* Defaults to {@code false}
*
* @param isUseClasspathJar {@code true} or {@code false}
* @return this operation instance
*/
public PitestOperation useClasspathJar(boolean isUseClasspathJar) {
if (isUseClasspathJar) {
options_.put("--useClasspathJar", TRUE);
} else {
options_.put("--useClasspathJar", FALSE);
}
return this;
}
/**
* Output verbose logging.
*
* Defaults to {@code false}
*
* @param isVerbose {@code true} or {@code false}
* @return this operation instance
*/
public PitestOperation verbose(boolean isVerbose) {
if (isVerbose) {
options_.put("--verbose", TRUE);
} else {
options_.put("--verbose", FALSE);
}
return this;
}
/**
* The verbosity of output.
*
* Defaults to {@code DEFAULT}
*
* @param verbosity the verbosity
* @return this operation instance
*/
public PitestOperation verbosity(String verbosity) {
options_.put("--verbosity", verbosity);
return this;
}
}
*
*
*
*
*
*
*
*
* finally {
* int++;
* int++;
* }
*
* But this will look confusing so PIT will assume no in-lining is taking place.
*
* finally {
* int++; int++;
* }
*
* This sort of pattern might not be common with integer addition, but things like string concatenation are likely
* to produce multiple similar instructions on the same line.
*
*
*