|
9 | 9 |
|
10 | 10 | import org.testng.TestNG; |
11 | 11 | import org.testng.TestNGException; |
| 12 | +import org.testng.annotations.SkipCloning; |
12 | 13 | import org.testng.collections.Lists; |
13 | 14 | import org.testng.collections.Maps; |
14 | 15 | import org.testng.xml.dom.ParentSetter; |
15 | 16 |
|
16 | 17 | import static org.testng.xml.XmlSuite.ParallelMode.skipDeprecatedValues; |
17 | 18 |
|
18 | 19 | /** This class describes the tag <test> in testng.xml. */ |
| 20 | +@SkipCloning |
19 | 21 | public class XmlTest implements Cloneable { |
20 | 22 |
|
21 | 23 | public static final int DEFAULT_TIMEOUT_MS = Integer.MAX_VALUE; |
@@ -75,6 +77,31 @@ private void init(XmlSuite suite, int index) { |
75 | 77 | // For YAML |
76 | 78 | public XmlTest() {} |
77 | 79 |
|
| 80 | + /** |
| 81 | + * This constructor acts as a copy constructor. Please note that it does not automatically |
| 82 | + * associate the copied {@link XmlTest} object with the current {@link XmlSuite} object and |
| 83 | + * requires it to be done explicitly. |
| 84 | + * |
| 85 | + * @param xmlTest - The {@link XmlTest} object to copy from. |
| 86 | + */ |
| 87 | + public XmlTest(XmlTest xmlTest) { |
| 88 | + XmlTest result = new XmlTest(); |
| 89 | + result.setName(getName()); |
| 90 | + result.setIncludedGroups(getIncludedGroups()); |
| 91 | + result.setExcludedGroups(getExcludedGroups()); |
| 92 | + result.setJUnit(isJUnit()); |
| 93 | + result.setParallel(getParallel()); |
| 94 | + result.setVerbose(getVerbose()); |
| 95 | + result.setParameters(getLocalParameters()); |
| 96 | + result.setXmlPackages(getXmlPackages()); |
| 97 | + result.setTimeOut(getTimeOut()); |
| 98 | + |
| 99 | + Map<String, List<String>> metagroups = getMetaGroups(); |
| 100 | + for (Map.Entry<String, List<String>> group : metagroups.entrySet()) { |
| 101 | + result.addMetaGroup(group.getKey(), group.getValue()); |
| 102 | + } |
| 103 | + } |
| 104 | + |
78 | 105 | public void setXmlPackages(List<XmlPackage> packages) { |
79 | 106 | m_xmlPackages = Lists.newArrayList(packages); |
80 | 107 | } |
@@ -482,8 +509,11 @@ public String toXml(String indent) { |
482 | 509 | * <p>The <classes> sub element is ignored for the moment. |
483 | 510 | * |
484 | 511 | * @return a clone of the current XmlTest |
| 512 | + * @Deprecated - This method stands deprecated as of TestNG 7.0.0. Please make use of |
| 513 | + * {@link XmlTest#XmlTest(XmlTest)} instead. |
485 | 514 | */ |
486 | 515 | @Override |
| 516 | + @Deprecated |
487 | 517 | public Object clone() { |
488 | 518 | XmlTest result = new XmlTest(getSuite()); |
489 | 519 |
|
|
0 commit comments