1 package org.testng.annotations;
2 
3 import static java.lang.annotation.ElementType.CONSTRUCTOR;
4 import static java.lang.annotation.ElementType.METHOD;
5 import static java.lang.annotation.ElementType.TYPE;
6 
7 import java.lang.annotation.Retention;
8 import java.lang.annotation.Target;
9 
10 /**
11  * Mark a class or a method as part of the test.
12  *
13  * @author Cedric Beust, Apr 26, 2004
14  */
15 @Retention(java.lang.annotation.RetentionPolicy.RUNTIME)
16 @Target({METHOD, TYPE, CONSTRUCTOR})
17 public @interface Test {
18   /**
19    * The list of groups this class/method belongs to.
20    */
groups()21   public String[] groups() default {};
22 
23   /**
24    * Whether methods on this class/method are enabled.
25    */
enabled()26   public boolean enabled() default true;
27 
28   /**
29    * The list of variables used to fill the parameters of this method.
30    * These variables must be defined in the property file.
31    *
32    * @deprecated Use @Parameters
33    */
34   @Deprecated
parameters()35   public String[] parameters() default {};
36 
37   /**
38    * The list of groups this method depends on.  Every method
39    * member of one of these groups is guaranteed to have been
40    * invoked before this method.  Furthermore, if any of these
41    * methods was not a SUCCESS, this test method will not be
42    * run and will be flagged as a SKIP.
43    */
dependsOnGroups()44   public String[] dependsOnGroups() default {};
45 
46   /**
47    * The list of methods this method depends on.  There is no guarantee
48    * on the order on which the methods depended upon will be run, but you
49    * are guaranteed that all these methods will be run before the test method
50    * that contains this annotation is run.  Furthermore, if any of these
51    * methods was not a SUCCESS, this test method will not be
52    * run and will be flagged as a SKIP.
53    *
54    * If some of these methods have been overloaded, all the overloaded
55    * versions will be run.
56    */
dependsOnMethods()57   public String[] dependsOnMethods() default {};
58 
59   /**
60    * The maximum number of milliseconds this test should take.
61    * If it hasn't returned after this time, it will be marked as a FAIL.
62    */
timeOut()63   public long timeOut() default 0;
64 
65   /**
66    * The maximum number of milliseconds that the total number of invocations on this test
67    * method should take.  This annotation will be ignored if the attribute invocationCount
68    * is not specified on this method.
69    * If it hasn't returned after this time, it will be marked as a FAIL.
70    */
invocationTimeOut()71   public long invocationTimeOut() default 0;
72 
73   /**
74    * The number of times this method should be invoked.
75    */
invocationCount()76   public int invocationCount() default 1;
77 
78   /**
79    * The size of the thread pool for this method.  The method will be invoked
80    * from multiple threads as specified by invocationCount.
81    * Note:  this attribute is ignored if invocationCount is not specified
82    */
threadPoolSize()83   public int threadPoolSize() default 0;
84 
85   /**
86    * The percentage of success expected from this method.
87    */
successPercentage()88   public int successPercentage() default 100;
89 
90   /**
91    * The name of the data provider for this test method.
92    * @see org.testng.annotations.DataProvider
93    */
dataProvider()94   public String dataProvider() default "";
95 
96   /**
97    * The class where to look for the data provider.  If not
98    * specified, the dataprovider will be looked on the class
99    * of the current test method or one of its super classes.
100    * If this attribute is specified, the data provider method
101    * needs to be static on the specified class.
102    */
dataProviderClass()103   public Class<?> dataProviderClass() default Object.class;
104 
105   /**
106    * If set to true, this test method will always be run even if it depends
107    * on a method that failed.  This attribute will be ignored if this test
108    * doesn't depend on any method or group.
109    */
alwaysRun()110   public boolean alwaysRun() default false;
111 
112   /**
113    * The description for this method.  The string used will appear in the
114    * HTML report and also on standard output if verbose >= 2.
115    */
description()116   public String description() default "";
117 
118   /**
119    * The list of exceptions that a test method is expected to throw.  If no
120    * exception or a different than one on this list is thrown, this test will be
121    * marked a failure.
122    */
expectedExceptions()123   public Class[] expectedExceptions() default {};
124 
125   /**
126    * If expectedExceptions was specified, its message must match the regular expression
127    * specified in this attribute.
128    */
expectedExceptionsMessageRegExp()129   public String expectedExceptionsMessageRegExp() default ".*";
130 
131   /**
132    * The name of the suite this test class should be placed in.  This
133    * attribute is ignore if @Test is not at the class level.
134    */
suiteName()135   public String suiteName() default "";
136 
137   /**
138    * The name of the test  this test class should be placed in.  This
139    * attribute is ignore if @Test is not at the class level.
140    */
testName()141   public String testName() default "";
142 
143   /**
144    * @deprecated Use singleThreaded
145    */
sequential()146   public boolean sequential() default false;
147 
148   /**
149    * If set to true, all the methods on this test class are guaranteed to run
150    * in the same thread, even if the tests are currently being run with parallel="true".
151    *
152    * This attribute can only be used at the class level and will be ignored
153    * if used at the method level.
154    */
singleThreaded()155   public boolean singleThreaded() default false;
156 
157   /**
158    * The name of the class that should be called to test if the test
159    * should be retried.
160    * @return String The name of the class that will test if a test method
161    * should be retried.
162    */
retryAnalyzer()163   public Class retryAnalyzer() default Class.class;
164 
165   /**
166    * If true and invocationCount is specified with a value > 1,
167    * then all invocations after a failure will be marked as a SKIP
168    * instead of a FAIL.
169    */
skipFailedInvocations()170   public boolean skipFailedInvocations() default false;
171 
172   /**
173    * If set to true, this test will run even if the methods
174    * it depends on are missing or excluded.
175    */
ignoreMissingDependencies()176   public boolean ignoreMissingDependencies() default false;
177 
178   /**
179    * The scheduling priority. Lower priorities will be scheduled first.
180    */
priority()181   int priority() default 0;
182 
183 }
184