Skip to content

Commit

Permalink
make excludedRunners parameter available via commandline
Browse files Browse the repository at this point in the history
  • Loading branch information
Henry Coles committed Jan 3, 2023
1 parent 1b0b7cb commit 2ed693e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
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 2ed693e

Please sign in to comment.