• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package org.testng.internal;
2 
3 
4 import org.testng.ITestClass;
5 import org.testng.ITestNGMethod;
6 import org.testng.xml.XmlClass;
7 import org.testng.xml.XmlTest;
8 
9 public class NoOpTestClass implements ITestClass {
10   private static final long serialVersionUID = -4544061405329040593L;
11 
12   protected Class m_testClass= null;
13 
14   // Test methods
15   protected ITestNGMethod[] m_beforeClassMethods= null;
16   protected ITestNGMethod[] m_beforeTestMethods= null;
17   protected ITestNGMethod[] m_testMethods= null;
18   protected ITestNGMethod[] m_afterClassMethods= null;
19   protected ITestNGMethod[] m_afterTestMethods= null;
20   protected ITestNGMethod[] m_beforeSuiteMethods= null;
21   protected ITestNGMethod[] m_afterSuiteMethods= null;
22   protected ITestNGMethod[] m_beforeTestConfMethods= null;
23   protected ITestNGMethod[] m_afterTestConfMethods= null;
24   protected ITestNGMethod[] m_beforeGroupsMethods= null;
25   protected ITestNGMethod[] m_afterGroupsMethods= null;
26 
27   private transient Object[] m_instances;
28   private long[] m_instanceHashes;
29 
30   private XmlTest m_xmlTest;
31 
32   private XmlClass m_xmlClass;
33 
NoOpTestClass()34   protected NoOpTestClass() {
35   }
36 
NoOpTestClass(ITestClass testClass)37   public NoOpTestClass(ITestClass testClass) {
38     m_testClass= testClass.getRealClass();
39     m_beforeSuiteMethods= testClass.getBeforeSuiteMethods();
40     m_beforeTestConfMethods= testClass.getBeforeTestConfigurationMethods();
41     m_beforeGroupsMethods= testClass.getBeforeGroupsMethods();
42     m_beforeClassMethods= testClass.getBeforeClassMethods();
43     m_beforeTestMethods= testClass.getBeforeTestMethods();
44     m_afterSuiteMethods= testClass.getAfterSuiteMethods();
45     m_afterTestConfMethods= testClass.getAfterTestConfigurationMethods();
46     m_afterGroupsMethods= testClass.getAfterGroupsMethods();
47     m_afterClassMethods= testClass.getAfterClassMethods();
48     m_afterTestMethods= testClass.getAfterTestMethods();
49     m_instances= testClass.getInstances(true);
50     m_instanceHashes= testClass.getInstanceHashCodes();
51     m_xmlTest = testClass.getXmlTest();
52     m_xmlClass = testClass.getXmlClass();
53   }
54 
setBeforeTestMethods(ITestNGMethod[] beforeTestMethods)55   public void setBeforeTestMethods(ITestNGMethod[] beforeTestMethods) {
56     m_beforeTestMethods= beforeTestMethods;
57   }
58 
setAfterTestMethod(ITestNGMethod[] afterTestMethods)59   public void setAfterTestMethod(ITestNGMethod[] afterTestMethods) {
60     m_afterTestMethods= afterTestMethods;
61   }
62 
63   /**
64    * @return Returns the afterClassMethods.
65    */
66   @Override
getAfterClassMethods()67   public ITestNGMethod[] getAfterClassMethods() {
68     return m_afterClassMethods;
69   }
70 
71   /**
72    * @return Returns the afterTestMethods.
73    */
74   @Override
getAfterTestMethods()75   public ITestNGMethod[] getAfterTestMethods() {
76     return m_afterTestMethods;
77   }
78 
79   /**
80    * @return Returns the beforeClassMethods.
81    */
82   @Override
getBeforeClassMethods()83   public ITestNGMethod[] getBeforeClassMethods() {
84     return m_beforeClassMethods;
85   }
86 
87   /**
88    * @return Returns the beforeTestMethods.
89    */
90   @Override
getBeforeTestMethods()91   public ITestNGMethod[] getBeforeTestMethods() {
92     return m_beforeTestMethods;
93   }
94 
95   /**
96    * @return Returns the testMethods.
97    */
98   @Override
getTestMethods()99   public ITestNGMethod[] getTestMethods() {
100     return m_testMethods;
101   }
102 
103   @Override
getBeforeSuiteMethods()104   public ITestNGMethod[] getBeforeSuiteMethods() {
105     return m_beforeSuiteMethods;
106   }
107 
108   @Override
getAfterSuiteMethods()109   public ITestNGMethod[] getAfterSuiteMethods() {
110     return m_afterSuiteMethods;
111   }
112 
113   @Override
getBeforeTestConfigurationMethods()114   public ITestNGMethod[] getBeforeTestConfigurationMethods() {
115     return m_beforeTestConfMethods;
116   }
117 
118   @Override
getAfterTestConfigurationMethods()119   public ITestNGMethod[] getAfterTestConfigurationMethods() {
120     return m_afterTestConfMethods;
121   }
122 
123   /**
124    * @return all @Configuration methods that should be invoked before certain groups
125    */
126   @Override
getBeforeGroupsMethods()127   public ITestNGMethod[] getBeforeGroupsMethods() {
128     return m_beforeGroupsMethods;
129   }
130 
131   /**
132    * @return all @Configuration methods that should be invoked after certain groups
133    */
134   @Override
getAfterGroupsMethods()135   public ITestNGMethod[] getAfterGroupsMethods() {
136     return m_afterGroupsMethods;
137   }
138 
139   /**
140    * @see org.testng.ITestClass#getInstanceCount()
141    */
142   @Override
getInstanceCount()143   public int getInstanceCount() {
144     return m_instances.length;
145   }
146 
147   /**
148    * @see org.testng.ITestClass#getInstanceHashCodes()
149    */
150   @Override
getInstanceHashCodes()151   public long[] getInstanceHashCodes() {
152     return m_instanceHashes;
153   }
154 
155   /**
156    * @see org.testng.ITestClass#getInstances(boolean)
157    */
158   @Override
getInstances(boolean reuse)159   public Object[] getInstances(boolean reuse) {
160     return m_instances;
161   }
162 
163   @Override
getName()164   public String getName() {
165     return m_testClass.getName();
166   }
167 
168   @Override
getRealClass()169   public Class getRealClass() {
170     return m_testClass;
171   }
172 
173   /**
174    * @see org.testng.IClass#addInstance(java.lang.Object)
175    */
176   @Override
addInstance(Object instance)177   public void addInstance(Object instance) {
178   }
179 
setTestClass(Class< ? > declaringClass)180   public void setTestClass(Class< ? > declaringClass) {
181     m_testClass = declaringClass;
182   }
183 
184   @Override
getTestName()185   public String getTestName() {
186     // TODO Auto-generated method stub
187     return null;
188   }
189 
190   @Override
getXmlTest()191   public XmlTest getXmlTest() {
192     return m_xmlTest;
193   }
194 
195   @Override
getXmlClass()196   public XmlClass getXmlClass() {
197     return m_xmlClass;
198   }
199 }
200