Skip to content

Commit

Permalink
Merge pull request #1134 from hcoles/feature/excluded_runner_param
Browse files Browse the repository at this point in the history
make excludedRunners parameter available via commandline and Ant.
  • Loading branch information
hcoles committed Jan 3, 2023
2 parents 1b0b7cb + 6d1de17 commit 9fb2a34
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 1 deletion.
4 changes: 4 additions & 0 deletions README.md
Expand Up @@ -8,6 +8,10 @@ Read all about it at http://pitest.org

## Releases

## 1.10.4 (unreleased)

* #1134 Add `excludedRunners` parameter to command line interface and Ant

## 1.10.3

* #1128 Bug fix - lines with repeated debug entries double counted
Expand Down
4 changes: 4 additions & 0 deletions pitest-ant/src/main/java/org/pitest/ant/PitestTask.java
Expand Up @@ -212,6 +212,10 @@ public void setExcludedGroups(final String value) {
this.setOption(ConfigOption.EXCLUDED_GROUPS, value);
}

public void setExcludedRunners(final String value) {
this.setOption(ConfigOption.EXCLUDED_RUNNERS, value);
}

public void setIncludedTestMethods(final String value) {
this.setOption(ConfigOption.INCLUDED_TEST_METHODS, value);
}
Expand Down
7 changes: 7 additions & 0 deletions pitest-ant/src/test/java/org/pitest/ant/PitestTaskTest.java
Expand Up @@ -232,6 +232,13 @@ public void shouldPassExcludedGroupsOptionToJavaTask() {
verify(this.arg).setValue("--excludedGroups=foo");
}

@Test
public void shouldPassExcludedRunnersToJavaTask() {
this.pitestTask.setExcludedRunners("foo");
this.pitestTask.execute(this.java);
verify(this.arg).setValue("--excludedRunners=foo");
}

@Test
public void shouldPassIncludedTestMethodsOptionToJavaTask() {
this.pitestTask.setIncludedTestMethods("footest");
Expand Down
Expand Up @@ -56,6 +56,7 @@
import static org.pitest.mutationtest.config.ConfigOption.EXCLUDED_CLASSES;
import static org.pitest.mutationtest.config.ConfigOption.EXCLUDED_GROUPS;
import static org.pitest.mutationtest.config.ConfigOption.EXCLUDED_METHOD;
import static org.pitest.mutationtest.config.ConfigOption.EXCLUDED_RUNNERS;
import static org.pitest.mutationtest.config.ConfigOption.EXCLUDED_TEST_CLASSES;
import static org.pitest.mutationtest.config.ConfigOption.EXPORT_LINE_COVERAGE;
import static org.pitest.mutationtest.config.ConfigOption.FAIL_WHEN_NOT_MUTATIONS;
Expand Down Expand Up @@ -127,6 +128,8 @@ public class OptionsParser {
private final ArgumentAcceptingOptionSpec<Boolean> failWhenNoMutations;
private final ArgumentAcceptingOptionSpec<Boolean> skipFailingTests;
private final ArgumentAcceptingOptionSpec<String> codePaths;

private final OptionSpec<String> excludedRunnersSpec;
private final OptionSpec<String> excludedGroupsSpec;
private final OptionSpec<String> includedGroupsSpec;
private final OptionSpec<String> includedTestMethodsSpec;
Expand Down Expand Up @@ -311,6 +314,10 @@ public OptionsParser(Predicate<String> dependencyFilter) {
.describedAs(
"Globs identifying classpath roots containing mutable code");

this.excludedRunnersSpec = parserAccepts(EXCLUDED_RUNNERS).withRequiredArg()
.ofType(String.class).withValuesSeparatedBy(',')
.describedAs("JUnit4 runners to exclude");

this.includedGroupsSpec = parserAccepts(INCLUDED_GROUPS).withRequiredArg()
.ofType(String.class).withValuesSeparatedBy(',')
.describedAs("TestNG groups/JUnit categories to include");
Expand Down Expand Up @@ -474,6 +481,8 @@ private ParseResult parseCommandLine(final ReportOptions data,

setTestGroups(userArgs, data);

data.setExcludedRunners(this.excludedRunnersSpec.values(userArgs));

data.setIncludedTestMethods(this.includedTestMethodsSpec.values(userArgs));
data.setJavaExecutable(this.javaExecutable.value(userArgs));

Expand Down
Expand Up @@ -382,6 +382,13 @@ public void shouldParseCommaSeparatedListOfIncludedTestMethods() {
.getIncludedTestMethods());
}

@Test
public void shouldParseCommaSeparatedListOfExcludedTestRunners() {
final ReportOptions actual = parseAddingRequiredArgs("--excludedRunners",
"foo,bar");
assertThat(actual.getExcludedRunners()).containsExactly("foo", "bar");
}

@Test
public void shouldParseMutationUnitSize() {
final ReportOptions actual = parseAddingRequiredArgs("--mutationUnitSize",
Expand Down
Expand Up @@ -153,10 +153,15 @@ public enum ConfigOption {
*/
INCLUDED_TEST_METHODS("includedTestMethods"),
/**
* TestNG groupsJUnit categories to exclude
* TestNG groups / JUnit categories to exclude
*/
EXCLUDED_GROUPS("excludedGroups"),

/**
* JUnit4 runners to exclude
*/
EXCLUDED_RUNNERS("excludedRunners"),

/**
* Whether to compute a full mutation matrix.
*/
Expand Down

0 comments on commit 9fb2a34

Please sign in to comment.