Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make excludedRunners parameter available via commandline and Ant. #1134

Merged
merged 2 commits into from
Jan 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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