Fixed missing maxMutationsPerClass parameter

This commit is contained in:
Erik C. Thauvin 2024-05-27 16:15:40 -07:00
parent ec0998caa4
commit e7ed7edc30
Signed by: erik
GPG key ID: 776702A6A2DA330E
2 changed files with 23 additions and 2 deletions

View file

@ -592,6 +592,17 @@ public class PitestOperation extends AbstractProcessOperation<PitestOperation> {
return this; return this;
} }
/**
* Maximum number of surviving mutants to allow without throwing an error.
*
* @param maxMutationsPerClass the max number
* @return this operation instance
*/
public PitestOperation maxMutationsPerClass(int maxMutationsPerClass) {
options.put("--maxMutationsPerClass", String.valueOf(maxMutationsPerClass));
return this;
}
/** /**
* Maximum number of surviving mutants to allow without throwing an error. * Maximum number of surviving mutants to allow without throwing an error.
* *

View file

@ -77,12 +77,13 @@ class PitestOperationTest {
"--fullMutationMatrix", "--fullMutationMatrix",
"--historyInputLocation", "--historyInputLocation",
"--historyOutputLocation", "--historyOutputLocation",
"--includeLaunchClasspath",
"--includedGroups", "--includedGroups",
"--includedTestMethods", "--includedTestMethods",
"--includeLaunchClasspath",
"--inputEncoding", "--inputEncoding",
"--jvmArgs", "--jvmArgs",
"--jvmPath", "--jvmPath",
"--maxMutationsPerClass",
"--maxSurviving", "--maxSurviving",
"--mutableCodePaths", "--mutableCodePaths",
"--mutationEngine", "--mutationEngine",
@ -122,8 +123,8 @@ class PitestOperationTest {
.excludedGroups(List.of(FOO, BAR)) .excludedGroups(List.of(FOO, BAR))
.excludedMethods("method") .excludedMethods("method")
.excludedMethods(List.of(FOO, BAR)) .excludedMethods(List.of(FOO, BAR))
.excludedTestClasses("test")
.excludedRunners("runners") .excludedRunners("runners")
.excludedTestClasses("test")
.exportLineCoverage(true) .exportLineCoverage(true)
.failWhenNoMutations(true) .failWhenNoMutations(true)
.features("feature") .features("feature")
@ -136,6 +137,7 @@ class PitestOperationTest {
.inputEncoding("encoding") .inputEncoding("encoding")
.jvmArgs("-XX:+UnlogregckDiagnosticVMOptions") .jvmArgs("-XX:+UnlogregckDiagnosticVMOptions")
.jvmPath("path") .jvmPath("path")
.maxMutationsPerClass(3)
.maxSurviving(1) .maxSurviving(1)
.mutableCodePaths("codePaths") .mutableCodePaths("codePaths")
.mutationEngine("engine") .mutationEngine("engine")
@ -456,6 +458,14 @@ class PitestOperationTest {
assertThat(op.options.get("--jvmPath")).isEqualTo(FOO); assertThat(op.options.get("--jvmPath")).isEqualTo(FOO);
} }
@Test
void maxMutationsPerClass() {
var op = new PitestOperation()
.fromProject(new BaseProject())
.maxMutationsPerClass(12);
assertThat(op.options.get("--maxMutationsPerClass")).isEqualTo("12");
}
@Test @Test
void maxSurviving() { void maxSurviving() {
var op = new PitestOperation() var op = new PitestOperation()