Skip to content

Commit

Permalink
testng-team#2974 XmlSuite: set*Groups overrides existing groups
Browse files Browse the repository at this point in the history
  • Loading branch information
dr29abrt committed Sep 1, 2023
1 parent 97dd348 commit 9b360eb
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions testng-core-api/src/main/java/org/testng/xml/XmlSuite.java
Original file line number Diff line number Diff line change
Expand Up @@ -853,18 +853,34 @@ public List<String> getIncludedGroups() {
}
}

private void initGroupsRun() {
if (m_xmlGroups == null) {
m_xmlGroups = new XmlGroups();
}
if (m_xmlGroups.getRun() == null) {
m_xmlGroups.setRun(new XmlRun());
}
}

public void addIncludedGroup(String g) {
m_includedGroups.add(g);
initGroupsRun();
m_xmlGroups.getRun().onInclude(g);
}

/** @param g - The list of groups to include. */
public void setIncludedGroups(List<String> g) {
m_includedGroups = g;
initGroupsRun();
List<String> includes = m_xmlGroups.getRun().getIncludes();
includes.clear();
includes.addAll(g);
}

/** @param g The excludedGrousps to set. */
public void setExcludedGroups(List<String> g) {
m_excludedGroups = g;
initGroupsRun();
List<String> excludes = m_xmlGroups.getRun().getExcludes();
excludes.clear();
excludes.addAll(g);
}

/**
Expand All @@ -882,7 +898,8 @@ public List<String> getExcludedGroups() {
}

public void addExcludedGroup(String g) {
m_excludedGroups.add(g);
initGroupsRun();
m_xmlGroups.getRun().onExclude(g);
}

public Boolean getGroupByInstances() {
Expand Down

0 comments on commit 9b360eb

Please sign in to comment.