01: package org.testng.xml;
02:
03: import java.util.Arrays;
04:
05: import org.testng.SuiteRunner;
06: import org.testng.internal.ClassHelper;
07: import org.testng.internal.Utils;
08: import org.testng.internal.annotations.AnnotationConfiguration;
09: import org.testng.internal.annotations.IAnnotationFinder;
10: import org.testng.internal.annotations.ITest;
11:
12: /**
13: * This class represents an XML <code><suite></code> made up of one test which is
14: * made up of <class> elements only. Given a testName "testName" it is equivalent to the
15: * following XML <suite>:
16: *
17: * <pre><code>
18: * <suite name ="Suite for testName">
19: * <test name ="testName">
20: * <classes>
21: * ...
22: * </classes>
23: * </test>
24: * </suite>
25: * </code></pre>
26: *
27: * This class is typically used to build a XML <suite> from command line class parameters.
28: * @author jolly
29: */
30:
31: // TODO CQ why does this class exist? Should'nt this be a constructor in XmlSuite, a
32: // factory helper or a simple class not extending XmlSuite outside this package?
33: // The code uses instanceof test on this class to set the annotation type.
34: public class ClassSuite extends XmlSuite {
35:
36: /**
37: * Constructs a <code>XmlSuite</code>. The suite has the following characteristics:
38: * <ul>
39: * <li>The suite name is "Suite for testName"</li>
40: * <li>The suite is made up of a single test named "testName"</li>
41: * <li>The test is made up of list <class> only</li>
42: * </ul>
43: *
44: * @param testName the suite and inner test name.
45: * @param classes the classes making up the suite test.
46: */
47: public ClassSuite(String testName, Class[] classes) {
48: super ();
49: XmlClass[] xmlClasses = Utils.classesToXmlClasses(classes);
50: XmlTest oneTest = new XmlTest(this );
51: oneTest.setName(testName);
52: oneTest.setXmlClasses(Arrays.asList(xmlClasses));
53: Class c = classes[0];
54: setName("Suite for " + testName); // Set the suite name to the test name, too
55: }
56: }
|