Top Description Methods
org.testng.annotations

public @Interface Test

extends Annotation
Annotations
@Retention:RUNTIME
@Target:METHOD, TYPE
Static Imports
java.lang.annotation.ElementType.METHOD, .ElementType.TYPE

Mark a class or a method as part of the test.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

the value (default false)
alwaysRun
()

If set to true, this test method will always be run even if it depends on a method that failed.

public CustomAttribute[]

Returns:

- An array of CustomAttribute that represents a set of custom attributes for a test method.
attributes
()

public String

Returns:

the value (default empty)
dataProvider
()

The name of the data provider for this test method.

public Class<?>

Returns:

the value (default same class)
dataProviderClass
()

The class where to look for the data provider.

public String
public String[]

Returns:

the value
dependsOnGroups
()

The list of groups this method depends on.

public String[]

Returns:

the value
dependsOnMethods
()

The list of methods this method depends on.

public String

Returns:

the value (default empty)
description
()

The description for this method.

public boolean

Returns:

the value (default true)
enabled
()

Whether methods on this class/method are enabled.

public Class<T>[]

Returns:

the value
expectedExceptions
()

The list of exceptions that a test method is expected to throw.

public String

Returns:

the value (default all matches)
expectedExceptionsMessageRegExp
()

If expectedExceptions was specified, its message must match the regular expression specified in this attribute.

public String[]

Returns:

the value
groups
()

The list of groups this class/method belongs to.

public boolean

Returns:

the value (default false)
ignoreMissingDependencies
()

If set to true, this test will run even if the methods it depends on are missing or excluded.

public int

Returns:

the value (default 1)
invocationCount
()

The number of times this method should be invoked.

public long

Returns:

the value (default 0)
invocationTimeOut
()

The maximum number of milliseconds that the total number of invocations on this test method should take.

public int

Returns:

the value (default 0)
priority
()

The scheduling priority.

public Class<? extends IRetryAnalyzer>

Returns:

String The name of the class that will test if a test method should be retried.
retryAnalyzer
()

The name of the class that should be called to test if the test should be retried.

public boolean

Returns:

true if single threaded (default false)
singleThreaded
()

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".

public boolean

Returns:

the value (default false)
skipFailedInvocations
()

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.

public int

Returns:

the value (default 100)
successPercentage
()

The percentage of success expected from this method.

public String

Returns:

the value (default empty)
suiteName
()

The name of the suite this test class should be placed in. This attribute is ignore if @Test is not at the class level.

public String

Returns:

the value (default empty)
testName
()

The name of the test this test class should be placed in. This attribute is ignore if @Test is not at the class level.

public int

Returns:

the value (default 0)
threadPoolSize
()

The size of the thread pool for this method.

public long

Returns:

the value (default 0)
timeOut
()

The maximum number of milliseconds this test should take.

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString

Method Detail

alwaysRunback to summary
public boolean alwaysRun()

If 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:boolean

the value (default false)

attributesback to summary
public CustomAttribute[] attributes()
Returns:CustomAttribute[]

- An array of CustomAttribute that represents a set of custom attributes for a test method.

dataProviderback to summary
public String dataProvider()

The name of the data provider for this test method.

Returns:String

the value (default empty)

See Also
org.testng.annotations.DataProvider
dataProviderClassback to summary
public Class<?> dataProviderClass()

The 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:Class<?>

the value (default same class)

dataProviderDynamicClassback to summary
public String dataProviderDynamicClass()
dependsOnGroupsback to summary
public String[] dependsOnGroups()

The 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:String[]

the value

dependsOnMethodsback to summary
public String[] dependsOnMethods()

The 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:String[]

the value

descriptionback to summary
public String description()

The description for this method. The string used will appear in the HTML report and also on standard output if verbose > 2.

Returns:String

the value (default empty)

enabledback to summary
public boolean enabled()

Whether methods on this class/method are enabled.

Returns:boolean

the value (default true)

expectedExceptionsback to summary
public Class<T>[] expectedExceptions()

The 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:Class<T>[]

the value

expectedExceptionsMessageRegExpback to summary
public String expectedExceptionsMessageRegExp()

If expectedExceptions was specified, its message must match the regular expression specified in this attribute.

Returns:String

the value (default all matches)

groupsback to summary
public String[] groups()

The list of groups this class/method belongs to.

Returns:String[]

the value

ignoreMissingDependenciesback to summary
public boolean ignoreMissingDependencies()

If set to true, this test will run even if the methods it depends on are missing or excluded.

Returns:boolean

the value (default false)

invocationCountback to summary
public int invocationCount()

The number of times this method should be invoked.

Returns:int

the value (default 1)

invocationTimeOutback to summary
public long invocationTimeOut()

The 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:long

the value (default 0)

priorityback to summary
public int priority()

The scheduling priority. Lower priorities will be scheduled first.

Returns:int

the value (default 0)

retryAnalyzerback to summary
public Class<? extends IRetryAnalyzer> retryAnalyzer()

The name of the class that should be called to test if the test should be retried.

Returns:Class<? extends IRetryAnalyzer>

String The name of the class that will test if a test method should be retried.

singleThreadedback to summary
public boolean singleThreaded()

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".

This attribute can only be used at the class level and will be ignored if used at the method level.

Returns:boolean

true if single threaded (default false)

skipFailedInvocationsback to summary
public boolean skipFailedInvocations()

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.

Returns:boolean

the value (default false)

successPercentageback to summary
public int successPercentage()

The percentage of success expected from this method.

Returns:int

the value (default 100)

suiteNameback to summary
public String suiteName()

The name of the suite this test class should be placed in. This attribute is ignore if @Test is not at the class level.

Returns:String

the value (default empty)

testNameback to summary
public String testName()

The name of the test this test class should be placed in. This attribute is ignore if @Test is not at the class level.

Returns:String

the value (default empty)

threadPoolSizeback to summary
public int threadPoolSize()

The 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:int

the value (default 0)

timeOutback to summary
public long timeOut()

The maximum number of milliseconds this test should take. If it hasn't returned after this time, it will be marked as a FAIL.

Returns:long

the value (default 0)