diff --git a/.github/workflows/bld.yml b/.github/workflows/bld.yml
index f1daec4..2b0ba38 100644
--- a/.github/workflows/bld.yml
+++ b/.github/workflows/bld.yml
@@ -1,38 +1,32 @@
name: bld-ci
-on: [push, pull_request, workflow_dispatch]
+on: [ push, pull_request, workflow_dispatch ]
jobs:
build-bld-project:
+ runs-on: ubuntu-latest
+
strategy:
matrix:
- java-version: [17, 21, 24]
- os: [ubuntu-latest, windows-latest, macos-latest]
-
- runs-on: ${{ matrix.os }}
+ java-version: [ 17, 20 ]
steps:
- name: Checkout source repository
- uses: actions/checkout@v4
+ uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up JDK ${{ matrix.java-version }}
- uses: actions/setup-java@v4
+ uses: actions/setup-java@v3
with:
- distribution: "zulu"
+ distribution: 'zulu'
java-version: ${{ matrix.java-version }}
- - name: Download dependencies [examples]
- working-directory: examples
+ - name: Grant execute permission for bld
+ run: chmod +x bld
+
+ - name: Download the dependencies
run: ./bld download
- - name: Run PIT tests [examples]
- working-directory: examples
- run: ./bld compile pit
-
- - name: Download dependencies
- run: ./bld download
-
- - name: Run tests
+ - name: Run tests with bld
run: ./bld compile test
diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml
index 508f6a5..f6122cd 100644
--- a/.github/workflows/pages.yml
+++ b/.github/workflows/pages.yml
@@ -30,14 +30,14 @@ jobs:
steps:
- name: Checkout source repository
- uses: actions/checkout@v4
+ uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up JDK 17
- uses: actions/setup-java@v4
+ uses: actions/setup-java@v3
with:
- distribution: "zulu"
+ distribution: 'zulu'
java-version: 17
- name: Build Javadocs
@@ -47,11 +47,11 @@ jobs:
uses: actions/configure-pages@v3
- name: Upload artifact
- uses: actions/upload-pages-artifact@v3
+ uses: actions/upload-pages-artifact@v1
with:
# Upload generated Javadocs repository
- path: "build/javadoc/"
+ path: 'build/javadoc/'
- name: Deploy to GitHub Pages
id: deployment
- uses: actions/deploy-pages@v4
+ uses: actions/deploy-pages@v1
\ No newline at end of file
diff --git a/.idea/bld.xml b/.idea/bld.xml
deleted file mode 100644
index 6600cee..0000000
--- a/.idea/bld.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
+ +1 + | ++ + + + + + | +package com.example; |
+ +2 + | ++ + + + + + | +|
+ +3 + | ++ + + + + + | +public class ExamplesLib { |
+ +4 + | ++ + + + + + | + public String getMessage() { |
+ +5 + | +
+
+1
+
+1. getMessage : replaced return value with "" for com/example/ExamplesLib::getMessage → KILLED + + + + |
+ return "Hello World!"; |
+ +6 + | ++ + + + + + | + } |
+ +7 + | ++ + + + + + | +} |
Mutations | ||
5 | ++ |
+
+
+
+ 1.1 |
+
+ +1 + | ++ + + + + + | +package com.example; |
+ +2 + | ++ + + + + + | +|
+ +3 + | ++ + + + + + | +import org.junit.jupiter.api.Test; |
+ +4 + | ++ + + + + + | +|
+ +5 + | ++ + + + + + | +import static org.junit.jupiter.api.Assertions.assertEquals; |
+ +6 + | ++ + + + + + | +|
+ +7 + | ++ + + + + + | +public class ExamplesTest { |
+ +8 + | ++ + + + + + | + @Test |
+ +9 + | ++ + + + + + | + void verifyHello() { |
+ +10 + | +
+
+1
+
+1. verifyHello : removed call to org/junit/jupiter/api/Assertions::assertEquals → SURVIVED + + + + |
+ assertEquals("Hello World!", new ExamplesLib().getMessage()); |
+ +11 + | ++ + + + + + | + } |
+ +12 + | ++ + + + + + | +} |
Mutations | ||
10 | ++ |
+
+
+
+ 1.1 |
+
Number of Classes | +Line Coverage | +Mutation Coverage | +Test Strength | +
---|---|---|---|
2 | +100% | +50% | +50% | +
Name | +Line Coverage | +Mutation Coverage | +Test Strength | +
---|---|---|---|
ExamplesLib.java | +100% |
+ 100% |
+ 100% |
+
ExamplesTest.java | +100% |
+ 0% |
+ 0% |
+
Number of Classes | +Line Coverage | +Mutation Coverage | +Test Strength | +
---|---|---|---|
2 | +100% | +50% | +50% | +
Name | +Number of Classes | +Line Coverage | +Mutation Coverage | +Test Strength | +
---|---|---|---|---|
com.example | +2 | +100% |
+ 50% |
+ 50% |
+
- * 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));
+ options.put("--classPath", String.join(",", Arrays.stream(path).filter(this::isNotBlank).toList()));
+ return this;
}
/**
@@ -178,34 +142,10 @@ public class PitestOperation extends AbstractProcessOperation
- * 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).
*
@@ -214,33 +154,11 @@ public class PitestOperation extends AbstractProcessOperation
- * Defaults to {@code false}
- *
- * @param isDryRun {@code true} or {@code false}
- * @return this operation instance
- */
- public PitestOperation dryRun(boolean isDryRun) {
- if (isDryRun) {
- options_.put("--dryRun", TRUE);
- } else {
- options_.put("--dryRun", FALSE);
+ options.put("--detectInlinedCode", FALSE);
}
return this;
}
@@ -321,7 +222,9 @@ public class PitestOperation extends AbstractProcessOperation
- * 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);
- }
+ options.put("--includedGroups", String.join(",", includedGroups.stream().filter(this::isNotBlank).toList()));
return this;
}
@@ -700,14 +500,6 @@ public class PitestOperation extends AbstractProcessOperation
- * 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));
+ options.put("--mutableCodePaths", String.join(",", Arrays.stream(path).filter(this::isNotBlank).toList()));
+ return this;
}
/**
@@ -860,56 +574,7 @@ public class PitestOperation extends AbstractProcessOperation
- * 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);
+ options.put("--mutableCodePaths", String.join(",", paths.stream().filter(this::isNotBlank).toList()));
return this;
}
@@ -925,22 +590,11 @@ public class PitestOperation extends AbstractProcessOperation
@@ -984,41 +629,13 @@ public class PitestOperation extends AbstractProcessOperation
- * 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.
+ * Comma separated 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}.
@@ -1028,11 +645,13 @@ public class PitestOperation extends AbstractProcessOperation
* Defaults to {@code HTML}.
@@ -1042,83 +661,10 @@ public class PitestOperation extends AbstractProcessOperation
- * 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
@@ -1162,9 +688,9 @@ public class PitestOperation extends AbstractProcessOperation
@@ -1251,7 +733,7 @@ public class PitestOperation extends AbstractProcessOperation
* 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
+ * @param test one ore more tests
* @return this operation instance
* @see #targetTests(Collection)
*/
public PitestOperation targetTests(String... test) {
- return targetTests(List.of(test));
+ options.put("--targetTests", String.join(",", Arrays.stream(test).filter(this::isNotBlank).toList()));
+ return this;
}
/**
- * A list of globs can be supplied to this parameter to limit the tests available to be run.
+ * A comma separated 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.
*
@@ -1301,18 +785,7 @@ public class PitestOperation extends AbstractProcessOperation
- * Defaults to {@code DEFAULT}
- *
- * @param verbosity the verbosity
- * @return this operation instance
- */
- public PitestOperation verbosity(String verbosity) {
- options_.put("--verbosity", verbosity);
- return this;
- }
-}
+}
\ No newline at end of file
diff --git a/src/test/java/rife/bld/extension/PitestOperationTest.java b/src/test/java/rife/bld/extension/PitestOperationTest.java
new file mode 100644
index 0000000..70d5ef8
--- /dev/null
+++ b/src/test/java/rife/bld/extension/PitestOperationTest.java
@@ -0,0 +1,494 @@
+/*
+ * Copyright 2023 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package rife.bld.extension;
+
+import org.junit.jupiter.api.Test;
+import rife.bld.BaseProject;
+import rife.bld.Project;
+import rife.bld.WebProject;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.util.List;
+import java.util.Set;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatCode;
+import static rife.bld.extension.PitestOperation.*;
+
+class PitestOperationTest {
+ private static final String AS_LIST = "as list";
+ private final static String BAR = "bar";
+ private final static String FOO = "foo";
+ private final static String FOOBAR = FOO + ',' + BAR;
+
+ @Test
+ void argLine() {
+ var op = new PitestOperation()
+ .fromProject(new BaseProject())
+ .argLine(FOO);
+ assertThat(op.options.get("--argLine")).isEqualTo(FOO);
+ }
+
+ @Test
+ void avoidCallsTo() {
+ var op = new PitestOperation()
+ .fromProject(new BaseProject())
+ .avoidCallsTo(FOO, BAR);
+ assertThat(op.options.get("--avoidCallsTo")).isEqualTo(FOOBAR);
+
+ op = new PitestOperation()
+ .fromProject(new Project())
+ .avoidCallsTo(List.of(FOO, BAR));
+ assertThat(op.options.get("--avoidCallsTo")).as(AS_LIST).isEqualTo(FOOBAR);
+ }
+
+ @Test
+ void classPath() {
+ var op = new PitestOperation()
+ .fromProject(new BaseProject())
+ .classPath(FOO, BAR);
+ assertThat(op.options.get("--classPath")).isEqualTo(FOOBAR);
+
+ op = new PitestOperation()
+ .fromProject(new Project())
+ .classPath(List.of(FOO, BAR));
+ assertThat(op.options.get("--classPath")).as(AS_LIST).isEqualTo(FOOBAR);
+ }
+
+ @Test
+ void classPathFile() {
+ var op = new PitestOperation()
+ .fromProject(new BaseProject())
+ .classPathFile(FOO);
+ assertThat(op.options.get("--classPathFile")).isEqualTo(FOO);
+ }
+
+ @Test
+ void coverageThreshold() {
+ var op = new PitestOperation()
+ .fromProject(new BaseProject())
+ .coverageThreshold(3);
+ assertThat(op.options.get("--coverageThreshold")).isEqualTo("3");
+
+ op = new PitestOperation()
+ .fromProject(new BaseProject())
+ .coverageThreshold(101);
+ assertThat(op.options.get("--coverageThreshold")).isNull();
+ }
+
+ @Test
+ void detectInlinedCode() {
+ var op = new PitestOperation()
+ .fromProject(new BaseProject())
+ .detectInlinedCode(true);
+ assertThat(op.options.get("--detectInlinedCode")).isEqualTo(TRUE);
+
+ op = new PitestOperation()
+ .fromProject(new Project())
+ .detectInlinedCode(false);
+ assertThat(op.options.get("--detectInlinedCode")).isEqualTo(FALSE);
+ }
+
+ @Test
+ void excludedClasses() {
+ var op = new PitestOperation()
+ .fromProject(new BaseProject())
+ .excludedClasses(FOO, BAR);
+ assertThat(op.options.get("--excludedClasses")).isEqualTo(FOOBAR);
+
+ op = new PitestOperation()
+ .fromProject(new Project())
+ .excludedClasses(Set.of(FOO, BAR));
+ assertThat(op.options.get("--excludedClasses")).as("as set").contains(FOO).contains(BAR).contains(",");
+ }
+
+ @Test
+ void excludedGroups() {
+ var op = new PitestOperation()
+ .fromProject(new BaseProject())
+ .excludedGroups(FOO, BAR);
+ assertThat(op.options.get("--excludedGroups")).isEqualTo(FOOBAR);
+
+ op = new PitestOperation()
+ .fromProject(new Project())
+ .excludedGroups(List.of(FOO, BAR));
+ assertThat(op.options.get("--excludedGroups")).as(AS_LIST).isEqualTo(FOOBAR);
+ }
+
+ @Test
+ void excludedMethods() {
+ var op = new PitestOperation()
+ .fromProject(new BaseProject())
+ .excludedMethods(FOO, BAR);
+ assertThat(op.options.get("--excludedMethods")).isEqualTo(FOOBAR);
+
+ op = new PitestOperation()
+ .fromProject(new Project())
+ .excludedMethods(List.of(FOO, BAR));
+ assertThat(op.options.get("--excludedMethods")).as(AS_LIST).isEqualTo(FOOBAR);
+ }
+
+ @Test
+ void excludedTests() {
+ var op = new PitestOperation()
+ .fromProject(new BaseProject())
+ .excludedTests(FOO, BAR);
+ assertThat(op.options.get("--excludedTests")).isEqualTo(FOOBAR);
+
+ op = new PitestOperation()
+ .fromProject(new Project())
+ .excludedTests(List.of(FOO, BAR));
+ assertThat(op.options.get("--excludedTests")).as("as list").isEqualTo(FOOBAR);
+ }
+
+ @Test
+ void execute() throws IOException {
+ var tmpDir = Files.createTempDirectory("bld-pitest");
+ tmpDir.toFile().deleteOnExit();
+ var op = new PitestOperation().
+ fromProject(new WebProject())
+ .reportDir(tmpDir.toAbsolutePath().toString())
+ .targetClasses("com.example.*")
+ .targetTests("com.example.*")
+ .verbose(true)
+ .failWhenNoMutations(false)
+ .sourceDirs("examples/src");
+
+ assertThatCode(op::execute).doesNotThrowAnyException();
+ assertThat(tmpDir).isEmptyDirectory();
+ }
+
+ @Test
+ void executeConstructProcessCommandList() {
+ var op = new PitestOperation().
+ fromProject(new WebProject())
+ .reportDir("outputdir")
+ .targetClasses("com.your.package.tobemutated*")
+ .targetTests("com.your.package.*")
+ .sourceDirs("parthsource");
+
+ assertThat(String.join(" ", op.executeConstructProcessCommandList())).endsWith(
+ " org.pitest.mutationtest.commandline.MutationCoverageReport " +
+ "--targetTests com.your.package.* " +
+ "--reportDir outputdir " +
+ "--targetClasses com.your.package.tobemutated* " +
+ "--sourceDirs parthsource");
+
+ op = new PitestOperation()
+ .fromProject(new BaseProject())
+ .reportDir("c:\\mutationReports")
+ .targetClasses("example.foo.*")
+ .sourceDirs("c:\\myProject\\src")
+ .targetTests("example.foo*")
+ .threads(2)
+ .excludedMethods("hashcode", "equals");
+ assertThat(String.join(" ", op.executeConstructProcessCommandList())).as("mutationReports").endsWith(
+ "org.pitest.mutationtest.commandline.MutationCoverageReport " +
+ "--targetTests example.foo* " +
+ "--threads 2 " +
+ "--excludedMethods hashcode,equals " +
+ "--reportDir c:\\mutationReports " +
+ "--targetClasses example.foo.* " +
+ "--sourceDirs c:\\myProject\\src");
+ }
+
+ @Test
+ void exportLineCoverage() {
+ var op = new PitestOperation()
+ .fromProject(new BaseProject())
+ .exportLineCoverage(true);
+ assertThat(op.options.get("--exportLineCoverage")).isEqualTo(TRUE);
+
+ op = new PitestOperation()
+ .fromProject(new Project())
+ .exportLineCoverage(false);
+ assertThat(op.options.get("--exportLineCoverage")).isEqualTo(FALSE);
+ }
+
+ @Test
+ void failWhenNoMutations() {
+ var op = new PitestOperation()
+ .fromProject(new BaseProject())
+ .failWhenNoMutations(true);
+ assertThat(op.options.get("--failWhenNoMutations")).isEqualTo(TRUE);
+
+ op = new PitestOperation()
+ .fromProject(new Project())
+ .failWhenNoMutations(false);
+ assertThat(op.options.get("--failWhenNoMutations")).isEqualTo(FALSE);
+ }
+
+ @Test
+ void features() {
+ var op = new PitestOperation()
+ .fromProject(new BaseProject())
+ .features(FOO, BAR);
+ assertThat(op.options.get("--features")).isEqualTo(FOOBAR);
+
+ op = new PitestOperation()
+ .fromProject(new Project())
+ .features(List.of(FOO, BAR));
+ assertThat(op.options.get("--features")).as(AS_LIST).isEqualTo(FOOBAR);
+ }
+
+ @Test
+ void historyInputLocation() {
+ var op = new PitestOperation()
+ .fromProject(new BaseProject())
+ .historyInputLocation(FOO);
+ assertThat(op.options.get("--historyInputLocation")).isEqualTo(FOO);
+ }
+
+ @Test
+ void historyOutputLocation() {
+ var op = new PitestOperation()
+ .fromProject(new BaseProject())
+ .historyOutputLocation(FOO);
+ assertThat(op.options.get("--historyOutputLocation")).isEqualTo(FOO);
+ }
+
+ @Test
+ void includeLaunchClasspath() {
+ var op = new PitestOperation()
+ .fromProject(new BaseProject())
+ .includeLaunchClasspath(true);
+ assertThat(op.options.get("--includeLaunchClasspath")).isEqualTo(TRUE);
+
+ op = new PitestOperation()
+ .fromProject(new Project())
+ .includeLaunchClasspath(false);
+ assertThat(op.options.get("--includeLaunchClasspath")).isEqualTo(FALSE);
+ }
+
+ @Test
+ void includedGroups() {
+ var op = new PitestOperation()
+ .fromProject(new BaseProject())
+ .includedGroups(FOO, BAR);
+ assertThat(op.options.get("--includedGroups")).isEqualTo(FOOBAR);
+
+ op = new PitestOperation()
+ .fromProject(new Project())
+ .includedGroups(List.of(FOO, BAR));
+ assertThat(op.options.get("--includedGroups")).as(AS_LIST).isEqualTo(FOOBAR);
+ }
+
+ @Test
+ void jvmArgs() {
+ var op = new PitestOperation()
+ .fromProject(new BaseProject())
+ .jvmArgs(FOO, BAR);
+ assertThat(op.options.get("--jvmArgs")).isEqualTo(FOOBAR);
+
+ op = new PitestOperation()
+ .fromProject(new Project())
+ .jvmArgs(List.of(FOO, BAR));
+ assertThat(op.options.get("--jvmArgs")).as(AS_LIST).isEqualTo(FOOBAR);
+ }
+
+ @Test
+ void jvmPath() {
+ var op = new PitestOperation()
+ .fromProject(new BaseProject())
+ .jvmPath(FOO);
+ assertThat(op.options.get("--jvmPath")).isEqualTo(FOO);
+ }
+
+ @Test
+ void mutableCodePaths() {
+ var op = new PitestOperation()
+ .fromProject(new BaseProject())
+ .mutableCodePaths(FOO, BAR);
+ assertThat(op.options.get("--mutableCodePaths")).isEqualTo(FOOBAR);
+
+ op = new PitestOperation()
+ .fromProject(new Project())
+ .mutableCodePaths(List.of(FOO, BAR));
+ assertThat(op.options.get("--mutableCodePaths")).as(AS_LIST).isEqualTo(FOOBAR);
+ }
+
+ @Test
+ void mutationThreshold() {
+ var op = new PitestOperation()
+ .fromProject(new BaseProject())
+ .mutationThreshold(3);
+ assertThat(op.options.get("--mutationThreshold")).isEqualTo("3");
+
+ op = new PitestOperation()
+ .fromProject(new BaseProject())
+ .mutationThreshold(101);
+ assertThat(op.options.get("--mutationThreshold")).isNull();
+ }
+
+ @Test
+ void mutators() {
+ var op = new PitestOperation()
+ .fromProject(new BaseProject())
+ .mutators(FOO, BAR);
+ assertThat(op.options.get("--mutators")).isEqualTo(FOOBAR);
+
+ op = new PitestOperation()
+ .fromProject(new Project())
+ .mutators(List.of(FOO, BAR));
+ assertThat(op.options.get("--mutators")).as(AS_LIST).isEqualTo(FOOBAR);
+ }
+
+ @Test
+ void outputEncoding() {
+ var op = new PitestOperation()
+ .fromProject(new BaseProject())
+ .outputEncoding(FOO);
+ assertThat(op.options.get("--outputEncoding")).isEqualTo(FOO);
+ }
+
+ @Test
+ void outputFormats() {
+ var op = new PitestOperation()
+ .fromProject(new BaseProject())
+ .outputFormats(FOO, BAR);
+ assertThat(op.options.get("--outputFormats")).isEqualTo(FOOBAR);
+
+ op = new PitestOperation()
+ .fromProject(new Project())
+ .outputFormats(List.of(FOO, BAR));
+ assertThat(op.options.get("--outputFormats")).as(AS_LIST).isEqualTo(FOOBAR);
+ }
+
+ @Test
+ void reportDir() {
+ var op = new PitestOperation()
+ .fromProject(new BaseProject())
+ .reportDir(FOO);
+ assertThat(op.options.get("--reportDir")).isEqualTo(FOO);
+ }
+
+ @Test
+ void skipFailingTests() {
+ var op = new PitestOperation()
+ .fromProject(new BaseProject())
+ .skipFailingTests(true);
+ assertThat(op.options.get("--skipFailingTests")).isEqualTo(TRUE);
+
+ op = new PitestOperation()
+ .fromProject(new Project())
+ .skipFailingTests(false);
+ assertThat(op.options.get("--skipFailingTests")).isEqualTo(FALSE);
+ }
+
+ @Test
+ void sourceDirs() {
+ var op = new PitestOperation()
+ .fromProject(new BaseProject())
+ .sourceDirs(FOO, BAR);
+ assertThat(op.options.get(SOURCE_DIRS)).isEqualTo(FOOBAR);
+
+ op = new PitestOperation()
+ .fromProject(new Project())
+ .sourceDirs(List.of(FOO, BAR));
+ assertThat(op.options.get(SOURCE_DIRS)).as(AS_LIST).isEqualTo(FOOBAR);
+ }
+
+ @Test
+ void targetClasses() {
+ var op = new PitestOperation()
+ .fromProject(new BaseProject())
+ .targetClasses(FOO, BAR);
+ assertThat(op.options.get("--targetClasses")).isEqualTo(FOOBAR);
+
+ op = new PitestOperation()
+ .fromProject(new Project())
+ .targetClasses(List.of(FOO, BAR));
+ assertThat(op.options.get("--targetClasses")).as(AS_LIST).isEqualTo(FOOBAR);
+ }
+
+ @Test
+ void targetTests() {
+ var op = new PitestOperation()
+ .fromProject(new BaseProject())
+ .targetTests(FOO, BAR);
+ assertThat(op.options.get("--targetTests")).isEqualTo(FOOBAR);
+
+ op = new PitestOperation()
+ .fromProject(new Project())
+ .targetTests(List.of(FOO, BAR));
+ assertThat(op.options.get("--targetTests")).as(AS_LIST).isEqualTo(FOOBAR);
+ }
+
+ @Test
+ void threads() {
+ var op = new PitestOperation()
+ .fromProject(new BaseProject())
+ .threads(3);
+ assertThat(op.options.get("--threads")).isEqualTo("3");
+ }
+
+ @Test
+ void timeoutConst() {
+ var op = new PitestOperation()
+ .fromProject(new BaseProject())
+ .timeoutConst(300);
+ assertThat(op.options.get("--timeoutConst")).isEqualTo("300");
+ }
+
+ @Test
+ void timeoutFactor() {
+ var op = new PitestOperation()
+ .fromProject(new BaseProject())
+ .timeoutFactor(5.25);
+ assertThat(op.options.get("--timeoutFactor")).isEqualTo("5.25");
+ }
+
+ @Test
+ void timestampedReports() {
+ var op = new PitestOperation()
+ .fromProject(new BaseProject())
+ .timestampedReports(true);
+ assertThat(op.options.get("--timestampedReports")).isEqualTo(TRUE);
+
+ op = new PitestOperation()
+ .fromProject(new Project())
+ .timestampedReports(false);
+ assertThat(op.options.get("--timestampedReports")).isEqualTo(FALSE);
+ }
+
+ @Test
+ void useClasspathJar() {
+ var op = new PitestOperation()
+ .fromProject(new BaseProject())
+ .useClasspathJar(true);
+ assertThat(op.options.get("--useClasspathJar")).isEqualTo(TRUE);
+
+ op = new PitestOperation()
+ .fromProject(new Project())
+ .useClasspathJar(false);
+ assertThat(op.options.get("--useClasspathJar")).isEqualTo(FALSE);
+ }
+
+ @Test
+ void verbose() {
+ var op = new PitestOperation()
+ .fromProject(new BaseProject())
+ .verbose(true);
+ assertThat(op.options.get("--verbose")).isEqualTo(TRUE);
+
+ op = new PitestOperation()
+ .fromProject(new Project())
+ .verbose(false);
+ assertThat(op.options.get("--verbose")).isEqualTo(FALSE);
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/rife/bld/extension/PitestOperationTests.java b/src/test/java/rife/bld/extension/PitestOperationTests.java
deleted file mode 100644
index c05af74..0000000
--- a/src/test/java/rife/bld/extension/PitestOperationTests.java
+++ /dev/null
@@ -1,982 +0,0 @@
-/*
- * Copyright 2023-2025 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package rife.bld.extension;
-
-import org.assertj.core.api.AutoCloseableSoftAssertions;
-import org.junit.jupiter.api.DisplayName;
-import org.junit.jupiter.api.Nested;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.condition.EnabledOnOs;
-import org.junit.jupiter.api.condition.OS;
-import rife.bld.BaseProject;
-import rife.bld.Project;
-import rife.bld.WebProject;
-import rife.bld.operations.exceptions.ExitStatusException;
-
-import java.io.File;
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-import java.util.List;
-import java.util.Set;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatCode;
-import static rife.bld.extension.PitestOperation.FALSE;
-import static rife.bld.extension.PitestOperation.TRUE;
-
-class PitestOperationTests {
- private static final String BAR = "bar";
- private static final File BAR_FILE = new File(BAR);
- private static final String FOO = "foo";
- private static final String FOOBAR = FOO + ',' + BAR;
- private static final File FOO_FILE = new File(FOO);
- private static final String FOOBAR_FORMAT =
- String.format("%s,%s", FOO_FILE.getAbsolutePath(), BAR_FILE.getAbsolutePath());
-
- @Nested
- @DisplayName("Execute Tests")
- class ExecuteTests {
- @Test
- void execute() throws IOException {
- var tmpDir = Files.createTempDirectory("bld-pitest-");
- tmpDir.toFile().deleteOnExit();
- var op = new PitestOperation().
- fromProject(new WebProject())
- .reportDir(tmpDir.toAbsolutePath().toString())
- .targetClasses("com.example.*")
- .targetTests("com.example.*")
- .verbose(true)
- .failWhenNoMutations(false)
- .sourceDirs("examples/src");
-
- assertThatCode(op::execute).doesNotThrowAnyException();
- assertThat(tmpDir).isEmptyDirectory();
- }
-
- @Test
- void executeConstructProcessCommandList() {
- var op = new PitestOperation().
- fromProject(new WebProject())
- .reportDir("outputdir")
- .targetClasses("com.your.package.tobemutated*")
- .targetTests("com.your.package.*")
- .sourceDirs("parthsource");
-
- assertThat(String.join(" ", op.executeConstructProcessCommandList())).endsWith(
- " org.pitest.mutationtest.commandline.MutationCoverageReport " +
- "--targetTests com.your.package.* " +
- "--reportDir outputdir " +
- "--targetClasses com.your.package.tobemutated* " +
- "--sourceDirs parthsource");
-
- op = new PitestOperation()
- .fromProject(new BaseProject())
- .reportDir("c:\\mutationReports")
- .targetClasses("example.foo.*")
- .sourceDirs("c:\\myProject\\src")
- .targetTests("example.foo*")
- .threads(2)
- .excludedMethods("hashcode", "equals");
- assertThat(String.join(" ", op.executeConstructProcessCommandList())).endsWith(
- "org.pitest.mutationtest.commandline.MutationCoverageReport " +
- "--targetTests example.foo* " +
- "--threads 2 " +
- "--excludedMethods hashcode,equals " +
- "--reportDir c:\\mutationReports " +
- "--targetClasses example.foo.* " +
- "--sourceDirs c:\\myProject\\src");
- }
-
- @Test
- void executeNoProject() {
- var op = new PitestOperation();
- assertThatCode(op::execute).isInstanceOf(ExitStatusException.class);
- }
-
- @Test
- void exportLineCoverageIsFalse() {
- var op = new PitestOperation()
- .fromProject(new Project())
- .exportLineCoverage(false);
- assertThat(op.options().get("--exportLineCoverage")).isEqualTo(FALSE);
- }
-
- @Test
- void exportLineCoverageIsTrue() {
- var op = new PitestOperation()
- .fromProject(new BaseProject())
- .exportLineCoverage(true);
- assertThat(op.options().get("--exportLineCoverage")).isEqualTo(TRUE);
- }
- }
-
- @Nested
- @DisplayName("Options Tests")
- class OptionsTests {
- @Test
- void argLine() {
- var op = new PitestOperation()
- .fromProject(new BaseProject())
- .argLine(FOO);
- assertThat(op.options().get("--argLine")).isEqualTo(FOO);
- }
-
- @Test
- void avoidCallsTo() {
- var op = new PitestOperation()
- .fromProject(new BaseProject())
- .avoidCallsTo(FOO, BAR);
- assertThat(op.options().get("--avoidCallsTo")).isEqualTo(FOOBAR);
- }
-
- @Test
- void avoidCallsToAsList() {
- var op = new PitestOperation()
- .fromProject(new Project())
- .avoidCallsTo(List.of(FOO, BAR));
- assertThat(op.options().get("--avoidCallsTo")).isEqualTo(FOOBAR);
- }
-
- @Test
- @EnabledOnOs(OS.LINUX)
- void checkAllParameters() throws IOException {
- var args = Files.readAllLines(Paths.get("src", "test", "resources", "pitest-args.txt"));
-
- assertThat(args).isNotEmpty();
-
- var params = new PitestOperation()
- .fromProject(new BaseProject())
- .argLine(FOO)
- .avoidCallsTo(FOO, BAR)
- .classPath(FOO, BAR)
- .classPathFile(FOO)
- .coverageThreshold(0)
- .detectInlinedCode(false)
- .dryRun(false)
- .excludedClasses("class")
- .excludedClasses(List.of(FOO, BAR))
- .excludedGroups("group")
- .excludedGroups(List.of(FOO, BAR))
- .excludedMethods("method")
- .excludedMethods(List.of(FOO, BAR))
- .excludedRunners("runners")
- .excludedTestClasses("test")
- .exportLineCoverage(true)
- .failWhenNoMutations(true)
- .features("feature")
- .fullMutationMatrix(true)
- .historyInputLocation("inputLocation")
- .historyOutputLocation("outputLocation")
- .includeLaunchClasspath(true)
- .includedGroups("group")
- .includedTestMethods("method")
- .inputEncoding("encoding")
- .jvmArgs("-XX:+UnlogregckDiagnosticVMOptions")
- .jvmPath("path")
- .maxMutationsPerClass(3)
- .maxSurviving(1)
- .mutableCodePaths("codePaths")
- .mutationEngine("engine")
- .mutationThreshold(0)
- .mutationUnitSize(1)
- .mutators(List.of(FOO, BAR))
- .outputEncoding("encoding")
- .outputFormats("json")
- .pluginConfiguration("key", "value")
- .projectBase("base")
- .reportDir("dir")
- .skipFailingTests(true)
- .targetClasses("class")
- .targetTests("test")
- .testStrengthThreshold(0)
- .threads(0)
- .timeoutConst(0)
- .timeoutFactor(0)
- .timestampedReports(true)
- .useClasspathJar(true)
- .verbose(true)
- .verbosity("default")
- .executeConstructProcessCommandList();
-
- try (var softly = new AutoCloseableSoftAssertions()) {
- for (var p : args) {
- var found = false;
- for (var a : params) {
- if (a.startsWith(p)) {
- found = true;
- break;
- }
- }
- softly.assertThat(found).as("%s not found", p).isTrue();
- }
- }
- }
-
- @Test
- void coverageThreshold() {
- var op = new PitestOperation()
- .fromProject(new BaseProject())
- .coverageThreshold(3);
- assertThat(op.options().get("--coverageThreshold")).isEqualTo("3");
- }
-
- @Test
- void coverageThresholdOutOfBounds() {
- var op = new PitestOperation()
- .fromProject(new BaseProject())
- .coverageThreshold(101);
- assertThat(op.options().get("--coverageThreshold")).isNull();
- }
-
- @Test
- void coverageThresholdOutOfBoundsNegative() {
- var op = new PitestOperation()
- .fromProject(new BaseProject())
- .coverageThreshold(-1);
- assertThat(op.options().get("--coverageThreshold")).isNull();
- }
-
- @Test
- void detectInlinedCodeIsFalse() {
- var op = new PitestOperation()
- .fromProject(new Project())
- .detectInlinedCode(false);
- assertThat(op.options().get("--detectInlinedCode")).isEqualTo(FALSE);
- }
-
- @Test
- void detectInlinedCodeIsTrue() {
- var op = new PitestOperation()
- .fromProject(new BaseProject())
- .detectInlinedCode(true);
- assertThat(op.options().get("--detectInlinedCode")).isEqualTo(TRUE);
- }
-
- @Test
- void features() {
- var op = new PitestOperation()
- .fromProject(new BaseProject())
- .features(FOO, BAR);
- assertThat(op.options().get("--features")).isEqualTo(FOOBAR);
- }
-
- @Test
- void featuresAsList() {
- var op = new PitestOperation()
- .fromProject(new Project())
- .features(List.of(FOO, BAR));
- assertThat(op.options().get("--features")).isEqualTo(FOOBAR);
- }
-
-
- @Test
- void inputEncoding() {
- var op = new PitestOperation()
- .fromProject(new BaseProject())
- .inputEncoding(FOO);
- assertThat(op.options().get("--inputEncoding")).isEqualTo(FOO);
- }
-
- @Test
- void maxSurviving() {
- var op = new PitestOperation()
- .fromProject(new Project())
- .maxSurviving(1);
- assertThat(op.options().get("--maxSurviving")).isEqualTo("1");
- }
-
- @Test
- void pluginConfiguration() {
- var op = new PitestOperation()
- .fromProject(new Project())
- .pluginConfiguration(FOO, BAR);
- assertThat(op.options().get("--pluginConfiguration")).isEqualTo(FOO + "=" + BAR);
- }
-
- @Test
- void projectBase() {
- var op = new PitestOperation().projectBase(FOO);
- assertThat(op.options().get("--projectBase")).isEqualTo(FOO);
- }
-
- @Test
- void projectBaseAsFile() {
- var op = new PitestOperation().projectBase(FOO_FILE);
- assertThat(op.options().get("--projectBase")).isEqualTo(FOO_FILE.getAbsolutePath());
- }
-
- @Test
- void projectBaseAsPath() {
- var op = new PitestOperation().projectBase(FOO_FILE.toPath());
- assertThat(op.options().get("--projectBase")).isEqualTo(FOO_FILE.getAbsolutePath());
- }
-
- @Test
- void skipFailingTestsIsFalse() {
- var op = new PitestOperation()
- .fromProject(new Project())
- .skipFailingTests(false);
- assertThat(op.options().get("--skipFailingTests")).isEqualTo(FALSE);
- }
-
- @Test
- void skipFailingTestsIsTrue() {
- var op = new PitestOperation()
- .fromProject(new BaseProject())
- .skipFailingTests(true);
- assertThat(op.options().get("--skipFailingTests")).isEqualTo(TRUE);
- }
-
- @Test
- void strengthThreshold() {
- var op = new PitestOperation()
- .fromProject(new Project())
- .testStrengthThreshold(6);
- assertThat(op.options().get("--testStrengthThreshold")).isEqualTo("6");
- }
-
- @Test
- void threads() {
- var op = new PitestOperation()
- .fromProject(new BaseProject())
- .threads(3);
- assertThat(op.options().get("--threads")).isEqualTo("3");
- }
-
- @Test
- void timestampedReportsIsFalse() {
- var op = new PitestOperation()
- .fromProject(new Project())
- .timestampedReports(false);
- assertThat(op.options().get("--timestampedReports")).isEqualTo(FALSE);
- }
-
- @Test
- void timestampedReportsIsTrue() {
- var op = new PitestOperation()
- .fromProject(new BaseProject())
- .timestampedReports(true);
- assertThat(op.options().get("--timestampedReports")).isEqualTo(TRUE);
- }
-
- @Nested
- @DisplayName("ClassPath Tests")
- class ClassPathTests {
- private static final String CLASS_PATH = "--classPath";
-
- @Test
- void classPath() {
- var op = new PitestOperation().classPath(FOO_FILE.toPath(), BAR_FILE.toPath());
- assertThat(op.options().get(CLASS_PATH)).isEqualTo(FOOBAR_FORMAT);
- }
-
- @Test
- void classPathAsFile() {
- var op = new PitestOperation()
- .fromProject(new BaseProject())
- .classPathFile(FOO);
- assertThat(op.options().get("--classPathFile")).isEqualTo(FOO);
- }
-
- @Test
- void classPathAsFileArray() {
- var op = new PitestOperation().classPath(FOO_FILE, BAR_FILE);
- assertThat(op.options().get(CLASS_PATH)).isEqualTo(FOOBAR_FORMAT);
- }
-
- @Test
- void classPathAsFileList() {
- var op = new PitestOperation().classPathFiles(List.of(FOO_FILE, BAR_FILE));
- assertThat(op.options().get(CLASS_PATH)).isEqualTo(FOOBAR_FORMAT);
- }
-
- @Test
- void classPathAsList() {
- var op = new PitestOperation()
- .fromProject(new Project())
- .classPath(List.of(FOO, BAR));
- assertThat(op.options().get(CLASS_PATH)).isEqualTo(FOOBAR);
- }
-
- @Test
- void classPathAsStringList() {
- var op = new PitestOperation().classPathPaths(List.of(FOO_FILE.toPath(), BAR_FILE.toPath()));
- assertThat(op.options().get(CLASS_PATH)).isEqualTo(FOOBAR_FORMAT);
- }
-
- @Test
- void useClasspathJarIsFalse() {
- var op = new PitestOperation()
- .fromProject(new Project())
- .useClasspathJar(false);
- assertThat(op.options().get("--useClasspathJar")).isEqualTo(FALSE);
- }
-
- @Test
- void useClasspathJarIsTrue() {
- var op = new PitestOperation()
- .fromProject(new BaseProject())
- .useClasspathJar(true);
- assertThat(op.options().get("--useClasspathJar")).isEqualTo(TRUE);
- }
- }
-
- @Nested
- @DisplayName("Excluded Tests")
- class ExcludedTests {
- @Test
- void excludedClasses() {
- var op = new PitestOperation()
- .fromProject(new BaseProject())
- .excludedClasses(FOO, BAR);
- assertThat(op.options().get("--excludedClasses")).isEqualTo(FOOBAR);
- }
-
- @Test
- void excludedClassesAsList() {
- var op = new PitestOperation()
- .fromProject(new Project())
- .excludedClasses(Set.of(FOO, BAR));
- assertThat(op.options().get("--excludedClasses")).contains(",");
- }
-
- @Test
- void excludedGroups() {
- var op = new PitestOperation()
- .fromProject(new BaseProject())
- .excludedGroups(FOO, BAR);
- assertThat(op.options().get("--excludedGroups")).isEqualTo(FOOBAR);
- }
-
- @Test
- void excludedGroupsAsList() {
- var op = new PitestOperation()
- .fromProject(new Project())
- .excludedGroups(List.of(FOO, BAR));
- assertThat(op.options().get("--excludedGroups")).isEqualTo(FOOBAR);
- }
-
- @Test
- void excludedMethods() {
- var op = new PitestOperation()
- .fromProject(new BaseProject())
- .excludedMethods(FOO, BAR);
- assertThat(op.options().get("--excludedMethods")).isEqualTo(FOOBAR);
-
- op = new PitestOperation()
- .fromProject(new Project())
- .excludedMethods(List.of(FOO, BAR));
- assertThat(op.options().get("--excludedMethods")).isEqualTo(FOOBAR);
- }
-
- @Test
- void excludedRunners() {
- var op = new PitestOperation()
- .fromProject(new BaseProject())
- .excludedRunners(FOO);
- assertThat(op.options().get("--excludedRunners")).isEqualTo(FOO);
- }
-
- @Test
- void excludedTests() {
- var op = new PitestOperation()
- .fromProject(new BaseProject())
- .excludedTestClasses(FOO, BAR);
- assertThat(op.options().get("--excludedTestClasses")).isEqualTo(FOOBAR);
- }
-
- @Test
- void excludedTestsAsList() {
- var op = new PitestOperation()
- .fromProject(new Project())
- .excludedTestClasses(List.of(FOO, BAR));
- assertThat(op.options().get("--excludedTestClasses")).isEqualTo(FOOBAR);
- }
- }
-
- @Nested
- @DisplayName("History Location Tests")
- class HistoryLocationTests {
- private static final String historyInputLocation = "--historyInputLocation";
- private static final String historyOutputLocation = "--historyOutputLocation";
- private final PitestOperation op = new PitestOperation().fromProject(new WebProject());
-
- @Test
- void historyInputLocationAsFile() {
- op.historyInputLocation(FOO_FILE);
- assertThat(op.options().get(historyInputLocation)).isEqualTo(FOO_FILE.getAbsolutePath());
- }
-
- @Test
- void historyInputLocationAsPath() {
- var op = new PitestOperation().historyInputLocation(FOO_FILE.toPath());
- assertThat(op.options().get(historyInputLocation)).isEqualTo(FOO_FILE.getAbsolutePath());
- }
-
- @Test
- void historyInputLocationAsString() {
- op.historyInputLocation(FOO);
- assertThat(op.options().get(historyInputLocation)).isEqualTo(FOO);
- }
-
- @Test
- void historyOutputLocationAsPath() {
- var op = new PitestOperation()
- .fromProject(new BaseProject())
- .historyOutputLocation(FOO_FILE.toPath());
- assertThat(op.options().get(historyOutputLocation)).isEqualTo(FOO_FILE.getAbsolutePath());
- }
-
- @Test
- void historyOutputLocationAsString() {
- var op = new PitestOperation()
- .fromProject(new BaseProject())
- .historyOutputLocation(FOO);
- assertThat(op.options().get(historyOutputLocation)).isEqualTo(FOO);
- }
- }
-
- @Nested
- @DisplayName("Include Test")
- class IncludeTest {
- @Test
- void includeLaunchClasspathIsFalse() {
- var op = new PitestOperation()
- .fromProject(new Project())
- .includeLaunchClasspath(false);
- assertThat(op.options().get("--includeLaunchClasspath")).isEqualTo(FALSE);
- }
-
- @Test
- void includeLaunchClasspathIsTrue() {
- var op = new PitestOperation()
- .fromProject(new BaseProject())
- .includeLaunchClasspath(true);
- assertThat(op.options().get("--includeLaunchClasspath")).isEqualTo(TRUE);
- }
-
- @Test
- void includedGroups() {
- var op = new PitestOperation()
- .fromProject(new BaseProject())
- .includedGroups(FOO, BAR);
- assertThat(op.options().get("--includedGroups")).isEqualTo(FOOBAR);
- }
-
- @Test
- void includedGroupsAsList() {
- var op = new PitestOperation()
- .fromProject(new Project())
- .includedGroups(List.of(FOO, BAR));
- assertThat(op.options().get("--includedGroups")).isEqualTo(FOOBAR);
- }
-
- @Test
- void includedTestMethods() {
- var op = new PitestOperation()
- .fromProject(new Project())
- .includedTestMethods(FOO);
- assertThat(op.options().get("--includedTestMethods")).isEqualTo(FOO);
- }
- }
-
- @Nested
- @DisplayName("JVM Tests")
- class JvmTests {
- @Test
- void jvmArgs() {
- var op = new PitestOperation()
- .fromProject(new BaseProject())
- .jvmArgs(FOO, BAR);
- assertThat(op.options().get("--jvmArgs")).isEqualTo(FOOBAR);
- }
-
- @Test
- void jvmArgsAsList() {
- var op = new PitestOperation()
- .fromProject(new Project())
- .jvmArgs(List.of(FOO, BAR));
- assertThat(op.options().get("--jvmArgs")).isEqualTo(FOOBAR);
- }
-
- @Test
- void jvmPath() {
- var op = new PitestOperation().jvmPath(FOO);
- assertThat(op.options().get("--jvmPath")).isEqualTo(FOO);
- }
-
- @Test
- void jvmPathAsFile() {
- var op = new PitestOperation().jvmPath(FOO_FILE);
- assertThat(op.options().get("--jvmPath")).isEqualTo(FOO_FILE.getAbsolutePath());
- }
-
- @Test
- void jvmPathAsPath() {
- var op = new PitestOperation().jvmPath(FOO_FILE.toPath());
- assertThat(op.options().get("--jvmPath")).isEqualTo(FOO_FILE.getAbsolutePath());
- }
- }
-
- @Nested
- @DisplayName("Mutable Code Paths Tests")
- class MutableCodePathsTests {
- private static final String MUTABLE_CODE_PATHS = "--mutableCodePaths";
-
- @Test
- void mutableCodePaths() {
- var op = new PitestOperation().mutableCodePaths(FOO, BAR);
- assertThat(op.options().get(MUTABLE_CODE_PATHS)).isEqualTo(FOOBAR);
- }
-
- @Test
- void mutableCodePathsAsFileArray() {
- var op = new PitestOperation().mutableCodePaths(FOO_FILE, BAR_FILE);
- assertThat(op.options().get(MUTABLE_CODE_PATHS)).isEqualTo(FOOBAR_FORMAT);
- }
-
- @Test
- void mutableCodePathsAsFileList() {
- var op = new PitestOperation().mutableCodePathsFiles(List.of(FOO_FILE, BAR_FILE));
- assertThat(op.options().get(MUTABLE_CODE_PATHS)).isEqualTo(FOOBAR_FORMAT);
- }
-
- @Test
- void mutableCodePathsAsPathArray() {
- var op = new PitestOperation().mutableCodePaths(FOO_FILE.toPath(), BAR_FILE.toPath());
- assertThat(op.options().get(MUTABLE_CODE_PATHS)).isEqualTo(FOOBAR_FORMAT);
- }
-
- @Test
- void mutableCodePathsAsPathList() {
- var op = new PitestOperation().mutableCodePathsPaths(List.of(FOO_FILE.toPath(), BAR_FILE.toPath()));
- assertThat(op.options().get(MUTABLE_CODE_PATHS)).isEqualTo(FOOBAR_FORMAT);
- }
-
- @Test
- void mutableCodePathsAsStringList() {
- var op = new PitestOperation().mutableCodePaths(List.of(FOO, BAR));
- assertThat(op.options().get(MUTABLE_CODE_PATHS)).isEqualTo(FOOBAR);
- }
- }
-
- @Nested
- @DisplayName("Mutation Tests")
- class MutationTests {
- @Test
- void failWhenNoMutationsIsFalse() {
- var op = new PitestOperation()
- .fromProject(new Project())
- .failWhenNoMutations(false);
- assertThat(op.options().get("--failWhenNoMutations")).isEqualTo(FALSE);
- }
-
- @Test
- void failWhenNoMutationsIsTrue() {
- var op = new PitestOperation()
- .fromProject(new BaseProject())
- .failWhenNoMutations(true);
- assertThat(op.options().get("--failWhenNoMutations")).isEqualTo(TRUE);
- }
-
- @Test
- void fullMutationMatrixIsFalse() {
- var op = new PitestOperation()
- .fromProject(new BaseProject())
- .fullMutationMatrix(false);
- assertThat(op.options().get("--fullMutationMatrix")).isEqualTo(FALSE);
- }
-
- @Test
- void fullMutationMatrixIsTrue() {
- var op = new PitestOperation()
- .fromProject(new BaseProject())
- .fullMutationMatrix(true);
- assertThat(op.options().get("--fullMutationMatrix")).isEqualTo(TRUE);
- }
-
- @Test
- void maxMutationsPerClass() {
- var op = new PitestOperation()
- .fromProject(new BaseProject())
- .maxMutationsPerClass(12);
- assertThat(op.options().get("--maxMutationsPerClass")).isEqualTo("12");
- }
-
- @Test
- void mutationEngine() {
- var op = new PitestOperation()
- .fromProject(new Project())
- .mutationEngine(FOO);
- assertThat(op.options().get("--mutationEngine")).isEqualTo(FOO);
- }
-
- @Test
- void mutationThreshold() {
- var op = new PitestOperation()
- .fromProject(new BaseProject())
- .mutationThreshold(3);
- assertThat(op.options().get("--mutationThreshold")).isEqualTo("3");
- }
-
- @Test
- void mutationThresholdOutOfBounds() {
- var op = new PitestOperation()
- .fromProject(new BaseProject())
- .mutationThreshold(101);
- assertThat(op.options().get("--mutationThreshold")).isNull();
- }
-
- @Test
- void mutationThresholdOutOfBoundsNegative() {
- var op = new PitestOperation()
- .fromProject(new BaseProject())
- .mutationThreshold(-1);
- assertThat(op.options().get("--mutationThreshold")).isNull();
- }
-
- @Test
- void mutationUnitSize() {
- var op = new PitestOperation()
- .fromProject(new Project())
- .mutationUnitSize(2);
- assertThat(op.options().get("--mutationUnitSize")).isEqualTo("2");
- }
-
- @Test
- void mutators() {
- var op = new PitestOperation()
- .fromProject(new BaseProject())
- .mutators(FOO, BAR);
- assertThat(op.options().get("--mutators")).isEqualTo(FOOBAR);
- }
-
- @Test
- void mutatorsAsList() {
- var op = new PitestOperation()
- .fromProject(new Project())
- .mutators(List.of(FOO, BAR));
- assertThat(op.options().get("--mutators")).isEqualTo(FOOBAR);
- }
- }
-
- @Nested
- @DisplayName("Output Tests")
- class OutputTests {
- private static final String OUTPUT_FORMATS = "--outputFormats";
-
- @Test
- void outputEncoding() {
- var op = new PitestOperation()
- .fromProject(new BaseProject())
- .outputEncoding(FOO);
- assertThat(op.options().get("--outputEncoding")).isEqualTo(FOO);
- }
-
- @Nested
- @DisplayName("Output Formats Tests")
- class OutputFormatsTests {
- @Test
- void outputFormats() {
- var op = new PitestOperation().outputFormats(FOO, BAR);
- assertThat(op.options().get(OUTPUT_FORMATS)).isEqualTo(FOO + ',' + BAR);
- }
-
- @Test
- void outputFormatsAsFileArray() {
- var op = new PitestOperation().outputFormats(FOO_FILE, BAR_FILE);
- assertThat(op.options().get(OUTPUT_FORMATS)).isEqualTo(FOOBAR_FORMAT);
- }
-
- @Test
- void outputFormatsAsFileList() {
- var op = new PitestOperation().outputFormatsFiles(List.of(FOO_FILE, BAR_FILE));
- assertThat(op.options().get(OUTPUT_FORMATS)).isEqualTo(FOOBAR_FORMAT);
- }
-
- @Test
- void outputFormatsAsPathArray() {
- var op = new PitestOperation().outputFormats(FOO_FILE.toPath(), BAR_FILE.toPath());
- assertThat(op.options().get(OUTPUT_FORMATS)).isEqualTo(FOOBAR_FORMAT);
- }
-
- @Test
- void outputFormatsAsPathList() {
- var op = new PitestOperation().outputFormatsPaths(List.of(FOO_FILE.toPath(), BAR_FILE.toPath()));
- assertThat(op.options().get(OUTPUT_FORMATS)).isEqualTo(FOOBAR_FORMAT);
- }
-
- @Test
- void outputFormatsAsStringList() {
- var op = new PitestOperation().outputFormats(List.of(FOO, BAR));
- assertThat(op.options().get(OUTPUT_FORMATS)).isEqualTo(FOO + ',' + BAR);
- }
- }
- }
-
- @Nested
- @DisplayName("Report Tests")
- class ReportTests {
- private static final String REPORT_DIR = "--reportDir";
-
- @Test
- void reportDirAsFile() {
- var op = new PitestOperation().reportDir(FOO_FILE);
- assertThat(op.options().get(REPORT_DIR)).isEqualTo(FOO_FILE.getAbsolutePath());
- }
-
- @Test
- void reportDirAsPath() {
- var op = new PitestOperation().reportDir(FOO_FILE.toPath());
- assertThat(op.options().get(REPORT_DIR)).isEqualTo(FOO_FILE.getAbsolutePath());
- }
-
- @Test
- void reportDirAsString() {
- var op = new PitestOperation().reportDir(FOO);
- assertThat(op.options().get(REPORT_DIR)).isEqualTo(FOO);
- }
- }
-
- @Nested
- @DisplayName("Source Directories Tests")
- class SourceDirectoriesTests {
- private static final String SOURCE_DIRS = "--sourceDirs";
-
- @Test
- void sourceDirs() {
- var op = new PitestOperation().sourceDirs(FOO, BAR);
- assertThat(op.options().get(SOURCE_DIRS)).isEqualTo(FOO + ',' + BAR);
- }
-
- @Test
- void sourceDirsAsFileArray() {
- var op = new PitestOperation().sourceDirs(FOO_FILE, BAR_FILE);
- assertThat(op.options().get(SOURCE_DIRS)).isEqualTo(FOOBAR_FORMAT);
- }
-
- @Test
- void sourceDirsAsFileList() {
- var op = new PitestOperation().sourceDirsFiles(List.of(FOO_FILE, BAR_FILE));
- assertThat(op.options().get(SOURCE_DIRS)).isEqualTo(FOOBAR_FORMAT);
- }
-
- @Test
- void sourceDirsAsPathArray() {
- var op = new PitestOperation().sourceDirs(FOO_FILE.toPath(), BAR_FILE.toPath());
- assertThat(op.options().get(SOURCE_DIRS)).isEqualTo(FOOBAR_FORMAT);
- }
-
- @Test
- void sourceDirsAsPathList() {
- var op = new PitestOperation().sourceDirsPaths(List.of(FOO_FILE.toPath(), BAR_FILE.toPath()));
- assertThat(op.options().get(SOURCE_DIRS)).isEqualTo(FOOBAR_FORMAT);
- }
-
- @Test
- void sourceDirsAsStringList() {
- var op = new PitestOperation().sourceDirs(List.of(FOO, BAR));
- assertThat(op.options().get(SOURCE_DIRS)).isEqualTo(FOO + ',' + BAR);
- }
- }
-
- @Nested
- @DisplayName("Target Tests")
- class TargetTests {
- @Test
- void targetClasses() {
- var op = new PitestOperation()
- .fromProject(new BaseProject())
- .targetClasses(FOO, BAR);
- assertThat(op.options().get("--targetClasses")).isEqualTo(FOOBAR);
- }
-
- @Test
- void targetClassesAsList() {
- var op = new PitestOperation()
- .fromProject(new Project())
- .targetClasses(List.of(FOO, BAR));
- assertThat(op.options().get("--targetClasses")).isEqualTo(FOOBAR);
- }
-
- @Test
- void targetTests() {
- var op = new PitestOperation()
- .fromProject(new BaseProject())
- .targetTests(FOO, BAR);
- assertThat(op.options().get("--targetTests")).isEqualTo(FOOBAR);
- }
-
- @Test
- void targetTestsAsList() {
- var op = new PitestOperation()
- .fromProject(new Project())
- .targetTests(List.of(FOO, BAR));
- assertThat(op.options().get("--targetTests")).isEqualTo(FOOBAR);
- }
- }
-
- @Nested
- @DisplayName("Timeout Tests")
- class TimeoutTests {
- @Test
- void timeoutConst() {
- var op = new PitestOperation()
- .fromProject(new BaseProject())
- .timeoutConst(300);
- assertThat(op.options().get("--timeoutConst")).isEqualTo("300");
- }
-
- @Test
- void timeoutFactor() {
- var op = new PitestOperation()
- .fromProject(new BaseProject())
- .timeoutFactor(5.25);
- assertThat(op.options().get("--timeoutFactor")).isEqualTo("5.25");
- }
- }
-
- @Nested
- @DisplayName("Verbose Tests")
- class VerboseTests {
- @Test
- void verboseIsFalse() {
- var op = new PitestOperation()
- .fromProject(new Project())
- .verbose(false);
- assertThat(op.options().get("--verbose")).isEqualTo(FALSE);
- }
-
- @Test
- void verboseIsTrue() {
- var op = new PitestOperation()
- .fromProject(new BaseProject())
- .verbose(true);
- assertThat(op.options().get("--verbose")).isEqualTo(TRUE);
- }
-
- @Test
- void verbosity() {
- var op = new PitestOperation()
- .fromProject(new Project())
- .verbosity(FOO);
- assertThat(op.options().get("--verbosity")).isEqualTo(FOO);
- }
- }
- }
-}
diff --git a/src/test/resources/pitest-args.txt b/src/test/resources/pitest-args.txt
deleted file mode 100644
index df24bfb..0000000
--- a/src/test/resources/pitest-args.txt
+++ /dev/null
@@ -1,48 +0,0 @@
---argLine
---avoidCallsTo
---classPath
---classPathFile
---coverageThreshold
---detectInlinedCode
---dryRun
---excludedClasses
---excludedGroups
---excludedMethods
---excludedRunners
---excludedTestClasses
---exportLineCoverage
---failWhenNoMutations
---features
---fullMutationMatrix
---historyInputLocation
---historyOutputLocation
---includedGroups
---includedTestMethods
---includeLaunchClasspath
---inputEncoding
---jvmArgs
---jvmPath
---maxMutationsPerClass
---maxSurviving
---mutableCodePaths
---mutationEngine
---mutationThreshold
---mutationUnitSize
---mutators
---outputEncoding
---outputFormats
---pluginConfiguration
---projectBase
---reportDir
---skipFailingTests
---sourceDirs
---targetClasses
---targetTests
---testStrengthThreshold
---threads
---timeoutConst
---timeoutFactor
---timestampedReports
---useClasspathJar
---verbose
---verbosity
- *
- *