Skip to content

Commit

Permalink
Merge pull request #1239 from johnathana/fix/comma-separated-exclude-…
Browse files Browse the repository at this point in the history
…groups

Handle comma separated excludedGroups
  • Loading branch information
hcoles authored Jul 3, 2023
2 parents eaa96dd + ac87b1f commit 2ebd45f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.util.LinkedList;
import java.util.List;

import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.xml.Xpp3Dom;

import java.util.Objects;
Expand Down Expand Up @@ -46,8 +47,10 @@ private void convertGroups(ReportOptions option, Xpp3Dom configuration) {
private List<String> extractStrings(String element, Xpp3Dom configuration) {
Xpp3Dom groups = configuration.getChild(element);
if (groups != null) {
String[] parts = groups.getValue().split(" ");
return Arrays.asList(parts);
return Arrays.stream(groups.getValue().split("[ ,]+"))
.filter(StringUtils::isNotBlank)
.map(String::trim)
.collect(Collectors.toList());
} else {
return Collections.emptyList();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,16 @@ public void shouldConvertMultipleSurefireGroupExcludes() throws Exception {
"com.example.Unit", "com.example.Fast");
}

@Test
public void shouldConvertMultipleSurefireGroupExcludesCommaSeparated() throws Exception {
this.surefireConfig = makeConfig("<excludedGroups>integration, regression</excludedGroups>");
ReportOptions actual = this.testee
.update(this.options, this.surefireConfig);

assertThat(actual.getGroupConfig().getExcludedGroups()).containsOnly(
"integration", "regression");
}

@Test
public void shouldNotUseSurefireGroupsWhenPitestIncludesSpecified()
throws Exception {
Expand Down

0 comments on commit 2ebd45f

Please sign in to comment.