Package org.testng.annotations
Annotation Interface Test
Mark a class or a method as part of the test.
-
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionboolean
If set to true, this test method will always be run even if it depends on a method that failed.The name of the data provider for this test method.Class<?>
The class where to look for the data provider.String[]
The list of groups this method depends on.String[]
The list of methods this method depends on.The description for this method.boolean
Whether methods on this class/method are enabled.Class[]
The list of exceptions that a test method is expected to throw.If expectedExceptions was specified, its message must match the regular expression specified in this attribute.String[]
The list of groups this class/method belongs to.boolean
If set to true, this test will run even if the methods it depends on are missing or excluded.int
The number of times this method should be invoked.long
The maximum number of milliseconds that the total number of invocations on this test method should take.int
The scheduling priority.Class<? extends IRetryAnalyzer>
The name of the class that should be called to test if the test should be retried.boolean
If set to true, all the methods on this test class are guaranteed to run in the same thread, even if the tests are currently being run with parallel="true".boolean
If true and invocationCount is specified with a value > 1, then all invocations after a failure will be marked as a SKIP instead of a FAIL.int
The percentage of success expected from this method.The name of the suite this test class should be placed in.The name of the test this test class should be placed in.int
The size of the thread pool for this method.long
The maximum number of milliseconds this test should take.
-
Element Details
-
groups
String[] groupsThe list of groups this class/method belongs to.- Returns:
- the value
- Default:
- {}
-
enabled
boolean enabledWhether methods on this class/method are enabled.- Returns:
- the value (default true)
- Default:
- true
-
dependsOnGroups
String[] dependsOnGroupsThe list of groups this method depends on. Every method member of one of these groups is guaranteed to have been invoked before this method. Furthermore, if any of these methods was not a SUCCESS, this test method will not be run and will be flagged as a SKIP.- Returns:
- the value
- Default:
- {}
-
dependsOnMethods
String[] dependsOnMethodsThe list of methods this method depends on. There is no guarantee on the order on which the methods depended upon will be run, but you are guaranteed that all these methods will be run before the test method that contains this annotation is run. Furthermore, if any of these methods was not a SUCCESS, this test method will not be run and will be flagged as a SKIP.If some of these methods have been overloaded, all the overloaded versions will be run.
- Returns:
- the value
- Default:
- {}
-
timeOut
long timeOutThe maximum number of milliseconds this test should take. If it hasn't returned after this time, it will be marked as a FAIL.- Returns:
- the value (default 0)
- Default:
- 0L
-
invocationTimeOut
long invocationTimeOutThe maximum number of milliseconds that the total number of invocations on this test method should take. This annotation will be ignored if the attribute invocationCount is not specified on this method. If it hasn't returned after this time, it will be marked as a FAIL.- Returns:
- the value (default 0)
- Default:
- 0L
-
invocationCount
int invocationCountThe number of times this method should be invoked.- Returns:
- the value (default 1)
- Default:
- 1
-
threadPoolSize
int threadPoolSizeThe size of the thread pool for this method. The method will be invoked from multiple threads as specified by invocationCount. Note: this attribute is ignored if invocationCount is not specified- Returns:
- the value (default 0)
- Default:
- 0
-
successPercentage
int successPercentageThe percentage of success expected from this method.- Returns:
- the value (default 100)
- Default:
- 100
-
dataProvider
String dataProviderThe name of the data provider for this test method.- Returns:
- the value (default empty)
- See Also:
- Default:
- ""
-
dataProviderClass
Class<?> dataProviderClassThe class where to look for the data provider. If not specified, the data provider will be looked on the class of the current test method or one of its super classes. If this attribute is specified, the data provider method needs to be static on the specified class.- Returns:
- the value (default same class)
- Default:
- java.lang.Object.class
-
dataProviderDynamicClass
String dataProviderDynamicClass- Default:
- ""
-
alwaysRun
boolean alwaysRunIf set to true, this test method will always be run even if it depends on a method that failed. This attribute will be ignored if this test doesn't depend on any method or group.- Returns:
- the value (default false)
- Default:
- false
-
description
String descriptionThe description for this method. The string used will appear in the HTML report and also on standard output if verbose > 2.- Returns:
- the value (default empty)
- Default:
- ""
-
expectedExceptions
Class[] expectedExceptionsThe list of exceptions that a test method is expected to throw. If no exception or a different than one on this list is thrown, this test will be marked a failure.- Returns:
- the value
- Default:
- {}
-
expectedExceptionsMessageRegExp
String expectedExceptionsMessageRegExpIf expectedExceptions was specified, its message must match the regular expression specified in this attribute.- Returns:
- the value (default all matches)
- Default:
- ".*"
-
suiteName
String suiteNameThe name of the suite this test class should be placed in. This attribute is ignore if @Test is not at the class level.- Returns:
- the value (default empty)
- Default:
- ""
-
testName
String testNameThe name of the test this test class should be placed in. This attribute is ignore if @Test is not at the class level.- Returns:
- the value (default empty)
- Default:
- ""
-
singleThreaded
boolean singleThreadedIf set to true, all the methods on this test class are guaranteed to run in the same thread, even if the tests are currently being run with parallel="true".This attribute can only be used at the class level and will be ignored if used at the method level.
- Returns:
- true if single threaded (default false)
- Default:
- false
-
retryAnalyzer
Class<? extends IRetryAnalyzer> retryAnalyzerThe name of the class that should be called to test if the test should be retried.- Returns:
- String The name of the class that will test if a test method should be retried.
- Default:
- org.testng.internal.annotations.DisabledRetryAnalyzer.class
-
skipFailedInvocations
boolean skipFailedInvocationsIf true and invocationCount is specified with a value > 1, then all invocations after a failure will be marked as a SKIP instead of a FAIL.- Returns:
- the value (default false)
- Default:
- false
-
ignoreMissingDependencies
boolean ignoreMissingDependenciesIf set to true, this test will run even if the methods it depends on are missing or excluded.- Returns:
- the value (default false)
- Default:
- false
-
priority
int priorityThe scheduling priority. Lower priorities will be scheduled first.- Returns:
- the value (default 0)
- Default:
- 0
-
attributes
CustomAttribute[] attributes- Returns:
- - An array of
CustomAttribute
that represents a set of custom attributes for a test method.
- Default:
- {}
-