ITestNGMethod.java revision 830ff4bf3fbfae0d63cb762b9c0d9a184feb58a3
1package org.testng; 2 3 4import java.io.Serializable; 5import java.lang.reflect.Method; 6import java.util.List; 7 8/** 9 * Describes a TestNG annotated method and the instance on which it will be invoked. 10 * 11 * This interface is not meant to be implemented by users. 12 * 13 * @author Cedric Beust, May 3, 2004 14 */ 15public interface ITestNGMethod extends Comparable, Serializable, Cloneable { 16 17 /** 18 * @return The real class on which this method was declared 19 * (can be different from getMethod().getDeclaringClass() if 20 * the test method was defined in a superclass). 21 */ 22 Class getRealClass(); 23 24 ITestClass getTestClass(); 25 26 /** 27 * Sets the test class having this method. This is not necessarily the declaring class. 28 * 29 * @param cls The test class having this method. 30 */ 31 void setTestClass(ITestClass cls); 32 33 /** 34 * Returns the corresponding Java test method. 35 * @return the corresponding Java test method. 36 */ 37 Method getMethod(); 38 39 /** 40 * Returns the method name. This is needed for serialization because 41 * methods are not Serializable. 42 * @return the method name. 43 */ 44 String getMethodName(); 45 46 /** 47 * @return All the instances the methods will be invoked upon. 48 * This will typically be an array of one object in the absence 49 * of an @Factory annotation. 50 */ 51 Object[] getInstances(); 52 53 /** 54 * Needed for serialization. 55 */ 56 long[] getInstanceHashCodes(); 57 58 /** 59 * @return The groups this method belongs to, possibly added to the groups 60 * declared on the class. 61 */ 62 String[] getGroups(); 63 64 /** 65 * @return The groups this method depends on, possibly added to the groups 66 * declared on the class. 67 */ 68 String[] getGroupsDependedUpon(); 69 70 /** 71 * If a group was not found. 72 */ 73 String getMissingGroup(); 74 public void setMissingGroup(String group); 75 76 /** 77 * Before and After groups 78 */ 79 public String[] getBeforeGroups(); 80 public String[] getAfterGroups(); 81 82 /** 83 * @return The methods this method depends on, possibly added to the methods 84 * declared on the class. 85 */ 86 String[] getMethodsDependedUpon(); 87 void addMethodDependedUpon(String methodName); 88 89 /** 90 * @return true if this method was annotated with @Test 91 */ 92 boolean isTest(); 93 94 /** 95 * @return true if this method was annotated with @Configuration 96 * and beforeTestMethod = true 97 */ 98 boolean isBeforeMethodConfiguration(); 99 100 /** 101 * @return true if this method was annotated with @Configuration 102 * and beforeTestMethod = false 103 */ 104 boolean isAfterMethodConfiguration(); 105 106 /** 107 * @return true if this method was annotated with @Configuration 108 * and beforeClassMethod = true 109 */ 110 boolean isBeforeClassConfiguration(); 111 112 /** 113 * @return true if this method was annotated with @Configuration 114 * and beforeClassMethod = false 115 */ 116 boolean isAfterClassConfiguration(); 117 118 /** 119 * @return true if this method was annotated with @Configuration 120 * and beforeSuite = true 121 */ 122 boolean isBeforeSuiteConfiguration(); 123 124 /** 125 * @return true if this method was annotated with @Configuration 126 * and afterSuite = true 127 */ 128 boolean isAfterSuiteConfiguration(); 129 130 /** 131 * @return <tt>true</tt> if this method is a @BeforeTest (@Configuration beforeTest=true) 132 */ 133 boolean isBeforeTestConfiguration(); 134 135 /** 136 * @return <tt>true</tt> if this method is an @AfterTest (@Configuration afterTest=true) 137 */ 138 boolean isAfterTestConfiguration(); 139 140 boolean isBeforeGroupsConfiguration(); 141 142 boolean isAfterGroupsConfiguration(); 143 144 /** 145 * @return The timeout in milliseconds. 146 */ 147 long getTimeOut(); 148 void setTimeOut(long timeOut); 149 150 /** 151 * @return the number of times this method needs to be invoked. 152 */ 153 int getInvocationCount(); 154 void setInvocationCount(int count); 155 156 /** 157 * @return the success percentage for this method (between 0 and 100). 158 */ 159 int getSuccessPercentage(); 160 161 /** 162 * @return The id of the thread this method was run in. 163 */ 164 String getId(); 165 166 void setId(String id); 167 168 long getDate(); 169 170 void setDate(long date); 171 172 /** 173 * Returns if this ITestNGMethod can be invoked from within IClass. 174 */ 175 boolean canRunFromClass(IClass testClass); 176 177 /** 178 * @return true if this method is alwaysRun=true 179 */ 180 boolean isAlwaysRun(); 181 182 /** 183 * @return the number of threads to be used when invoking the method on parallel 184 */ 185 int getThreadPoolSize(); 186 187 void setThreadPoolSize(int threadPoolSize); 188 189 public String getDescription(); 190 191 public void incrementCurrentInvocationCount(); 192 public int getCurrentInvocationCount(); 193 public void setParameterInvocationCount(int n); 194 public int getParameterInvocationCount(); 195 196 public ITestNGMethod clone(); 197 198 public IRetryAnalyzer getRetryAnalyzer(); 199 public void setRetryAnalyzer(IRetryAnalyzer retryAnalyzer); 200 201 public boolean skipFailedInvocations(); 202 public void setSkipFailedInvocations(boolean skip); 203 204 /** 205 * The time under which all invocationCount methods need to complete by. 206 */ 207 public long getInvocationTimeOut(); 208 209 public boolean ignoreMissingDependencies(); 210 public void setIgnoreMissingDependencies(boolean ignore); 211 212 /** 213 * Which invocation numbers of this method should be used (only applicable 214 * if it uses a data provider). If this value is an empty list, use all the values 215 * returned from the data provider. These values are read from the XML file in 216 * the <include invocationNumbers="..."> tag. 217 */ 218 public List<Integer> getInvocationNumbers(); 219 public void setInvocationNumbers(List<Integer> numbers); 220 221 /** 222 * The list of invocation numbers that failed, which is only applicable for 223 * methods that have a data provider. 224 */ 225 public void addFailedInvocationNumber(int number); 226 public List<Integer> getFailedInvocationNumbers(); 227 228 /** 229 * The scheduling priority. Lower priorities get scheduled first. 230 */ 231 public int getPriority(); 232 public void setPriority(int priority); 233} 234