01: package org.testng;
02:
03: import java.util.Comparator;
04:
05: import org.testng.xml.XmlSuite;
06:
07: /**
08: * This class logs the result of an entire Test Suite (defined by a
09: * property file).
10: *
11: * @author Cedric Beust, May 10, 2004
12: *
13: */
14: public class SuiteResult implements ISuiteResult, Comparable {
15: /* generated */
16: private static final long serialVersionUID = 6778513869858860756L;
17: private String m_propertyFileName = null;
18: private XmlSuite m_suite = null;
19: private ITestContext m_testContext = null;
20:
21: public static final Comparator COMPARATOR = new Comparator<SuiteResult>() {
22: public int compare(SuiteResult o1, SuiteResult o2) {
23: return o1.getPropertyFileName().compareTo(
24: o2.getPropertyFileName());
25: }
26:
27: @Override
28: public boolean equals(Object obj) {
29: return super .equals(obj);
30: }
31: };
32:
33: /**
34: * @param propertyFileName
35: * @param tr
36: */
37: public SuiteResult(String propertyFileName, ITestContext tr) {
38: m_propertyFileName = propertyFileName;
39: m_testContext = tr;
40: }
41:
42: public SuiteResult(XmlSuite suite, ITestContext tr) {
43: m_suite = suite;
44: m_testContext = tr;
45: }
46:
47: /**
48: * @return Returns the propertyFileName.
49: */
50: public String getPropertyFileName() {
51: return m_propertyFileName;
52: }
53:
54: /**
55: * @return Returns the singleTestRunner.
56: */
57: public ITestContext getTestContext() {
58: return m_testContext;
59: }
60:
61: /**
62: * @return Returns the suite.
63: */
64: public XmlSuite getSuite() {
65: return m_suite;
66: }
67:
68: public int compareTo(Object o) {
69: int result = 0;
70: try {
71: SuiteResult other = (SuiteResult) o;
72: String n1 = getTestContext().getName();
73: String n2 = other.getTestContext().getName();
74: result = n1.compareTo(n2);
75: } catch (Exception ex) {
76: ex.printStackTrace();
77: }
78:
79: return result;
80: }
81:
82: /**
83: * Returns the test context name.
84: * {@inheritDoc}
85: */
86: @Override
87: public String toString() {
88: return "[SuiteResult " + getTestContext().getName() + "]";
89: }
90:
91: }
|