Class XmlTest

java.lang.Object
org.testng.xml.XmlTest
All Implemented Interfaces:
Cloneable

public class XmlTest extends Object implements Cloneable
This class describes the tag <test> in testng.xml.
  • Field Details

    • DEFAULT_TIMEOUT_MS

      public static final int DEFAULT_TIMEOUT_MS
      See Also:
    • m_suite

      private XmlSuite m_suite
    • m_name

      private String m_name
    • m_verbose

      private Integer m_verbose
    • m_isJUnit

      private Boolean m_isJUnit
    • m_threadCount

      private int m_threadCount
    • m_xmlClasses

      private List<XmlClass> m_xmlClasses
    • m_parameters

      private Map<String,String> m_parameters
    • m_parallel

      private XmlSuite.ParallelMode m_parallel
    • m_methodSelectors

      private List<XmlMethodSelector> m_methodSelectors
    • m_xmlPackages

      private List<XmlPackage> m_xmlPackages
    • m_timeOut

      private String m_timeOut
    • m_skipFailedInvocationCounts

      private Boolean m_skipFailedInvocationCounts
    • m_failedInvocationNumbers

      private Map<String,List<Integer>> m_failedInvocationNumbers
    • m_preserveOrder

      private Boolean m_preserveOrder
    • m_index

      private int m_index
    • m_groupByInstances

      private Boolean m_groupByInstances
    • m_allowReturnValues

      private Boolean m_allowReturnValues
    • m_xmlDependencyGroups

      private Map<String,String> m_xmlDependencyGroups
    • m_xmlGroups

      private XmlGroups m_xmlGroups
  • Constructor Details

    • XmlTest

      public XmlTest(XmlSuite suite, int index)
      Constructs a XmlTest and adds it to suite's list of tests.
      Parameters:
      suite - the parent suite.
      index - the index of this test tag in testng.xml
    • XmlTest

      public XmlTest(XmlSuite suite)
    • XmlTest

      public XmlTest()
  • Method Details

    • init

      private void init(XmlSuite suite, int index)
    • setXmlPackages

      public void setXmlPackages(List<XmlPackage> packages)
    • getXmlPackages

      public List<XmlPackage> getXmlPackages()
    • getPackages

      public List<XmlPackage> getPackages()
    • setPackages

      public void setPackages(List<XmlPackage> p)
    • getMethodSelectors

      public List<XmlMethodSelector> getMethodSelectors()
    • setMethodSelectors

      public void setMethodSelectors(List<XmlMethodSelector> methodSelectors)
    • getSuite

      public final XmlSuite getSuite()
      Returns the suite this test is part of.
      Returns:
      the suite this test is part of.
    • getIncludedGroups

      public List<String> getIncludedGroups()
      Returns:
      the includedGroups.
    • isGroupFilteringDisabled

      public boolean isGroupFilteringDisabled()
    • getXmlClasses

      public List<XmlClass> getXmlClasses()
      Returns:
      Returns the classes.
    • getClasses

      public List<XmlClass> getClasses()
    • setClasses

      public void setClasses(List<XmlClass> c)
    • setXmlClasses

      public void setXmlClasses(List<XmlClass> classes)
      Sets the XML Classes.
      Parameters:
      classes - The classes to set.
    • getName

      public String getName()
      Returns:
      Returns the name.
    • setName

      public void setName(String name)
      Parameters:
      name - The name to set.
    • setVerbose

      public void setVerbose(int v)
      Parameters:
      v - - Verbosity level.
    • getThreadCount

      public int getThreadCount()
    • setThreadCount

      public void setThreadCount(int threadCount)
    • setIncludedGroups

      public void setIncludedGroups(List<String> g)
    • setExcludedGroups

      public void setExcludedGroups(List<String> g)
    • getExcludedGroups

      public List<String> getExcludedGroups()
    • addIncludedGroup

      public void addIncludedGroup(String g)
    • addExcludedGroup

      public void addExcludedGroup(String g)
    • getVerbose

      public int getVerbose()
      Returns:
      Returns the verbose.
    • getGroupByInstances

      public boolean getGroupByInstances()
    • setGroupByInstances

      public void setGroupByInstances(boolean f)
    • isJUnit

      public boolean isJUnit()
      Returns:
      Returns the isJUnit.
    • setJUnit

      public void setJUnit(boolean isJUnit)
      Parameters:
      isJUnit - The isJUnit to set.
    • setJunit

      public void setJunit(boolean isJUnit)
    • setSkipFailedInvocationCounts

      public void setSkipFailedInvocationCounts(boolean skip)
    • skipFailedInvocationCounts

      public boolean skipFailedInvocationCounts()
      Returns:
      Returns the isJUnit.
    • addMetaGroup

      public void addMetaGroup(String name, List<String> metaGroup)
    • addMetaGroup

      public void addMetaGroup(String name, String... metaGroup)
    • setMetaGroups

      public void setMetaGroups(Map<String,List<String>> metaGroups)
    • getMetaGroups

      public Map<String,List<String>> getMetaGroups()
      Returns:
      Returns the metaGroups.
    • setParameters

      public void setParameters(Map<String,String> parameters)
      Parameters:
      parameters - - A Map of parameters.
    • addParameter

      public void addParameter(String key, String value)
    • getParameter

      public String getParameter(String name)
    • getAllParameters

      public Map<String,String> getAllParameters()
      Returns:
      the parameters defined in this test tag and the tags above it.
    • getLocalParameters

      public Map<String,String> getLocalParameters()
      Returns:
      the parameters defined in this tag, and only this test tag. To retrieve the inherited parameters as well, call getAllParameters().
    • setParallel

      public void setParallel(XmlSuite.ParallelMode parallel)
    • getParallel

      public XmlSuite.ParallelMode getParallel()
    • getTimeOut

      public String getTimeOut()
    • getTimeOut

      public long getTimeOut(long def)
    • setTimeOut

      public void setTimeOut(long timeOut)
    • setTimeOut

      private void setTimeOut(String timeOut)
    • setScript

      public void setScript(XmlScript script)
    • getScript

      public XmlScript getScript()
    • toXml

      public String toXml(String indent)
    • clone

      public Object clone()
      Clone the source XmlTest by including: - test attributes - groups definitions - parameters

      The <classes> sub element is ignored for the moment.

      Overrides:
      clone in class Object
      Returns:
      a clone of the current XmlTest
    • getInvocationNumbers

      public List<Integer> getInvocationNumbers(String method)
      Convenience method to cache the ordering numbers for methods.
      Parameters:
      method - The method name
      Returns:
      The invocation numbers of the method
    • setPreserveOrder

      public void setPreserveOrder(Boolean preserveOrder)
    • getPreserveOrder

      public Boolean getPreserveOrder()
    • setSuite

      public void setSuite(XmlSuite result)
    • getAllowReturnValues

      public Boolean getAllowReturnValues()
    • setAllowReturnValues

      public void setAllowReturnValues(Boolean allowReturnValues)
    • getIndex

      public int getIndex()
      Note that this attribute does not come from the XML file, it's calculated internally and represents the order in which this test tag was found in its <suite> tag. It's used to calculate the ordering of the tests when preserve-test-order is true.
      Returns:
      The value
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • addXmlDependencyGroup

      public void addXmlDependencyGroup(String group, String dependsOn)
    • getXmlDependencyGroups

      public Map<String,String> getXmlDependencyGroups()
    • setXmlDependencyGroups

      public void setXmlDependencyGroups(Map<String,String> xmlDependencyGroups)
    • setXmlSuite

      public void setXmlSuite(XmlSuite suite)
    • setGroups

      public void setGroups(XmlGroups xmlGroups)
    • getXmlGroups

      public XmlGroups getXmlGroups()
    • nameMatchesAny

      public boolean nameMatchesAny(List<String> names)
      Parameters:
      names - The list of names to check.
      Returns:
      true if the current test's name matches with any of the given names.