All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.testng.internal.OverrideProcessor Maven / Gradle / Ivy

The newest version!
package org.testng.internal;

import java.util.Arrays;
import java.util.Collection;
import org.testng.xml.IPostProcessor;
import org.testng.xml.XmlSuite;
import org.testng.xml.XmlTest;

/** Override the groups included in the XML file with groups specified on the command line. */
public class OverrideProcessor implements IPostProcessor {

  private final String[] m_groups;
  private final String[] m_excludedGroups;

  public OverrideProcessor(String[] groups, String[] excludedGroups) {
    m_groups = groups;
    m_excludedGroups = excludedGroups;
  }

  @Override
  public Collection process(Collection suites) {
    for (XmlSuite s : suites) {
      if (m_groups != null && m_groups.length > 0) {
        for (XmlTest t : s.getTests()) {
          t.setIncludedGroups(Arrays.asList(m_groups));
        }
      }

      if (m_excludedGroups != null && m_excludedGroups.length > 0) {
        for (XmlTest t : s.getTests()) {
          t.setExcludedGroups(Arrays.asList(m_excludedGroups));
        }
      }
    }

    return suites;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy